RSS Forums RSS
Please support our HTML and CSS advertiser: Lunarpages Web Hosting

Frame detection possible?

Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 108
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: Frame detection possible?

  #2  
May 22nd, 2006
well, you can check this way:
if (top.location != location) {
     alert("In A Frame");
}
But I'm not sure if you can do it like a conditional compiler directive. I know you could write to the page with something fun like:
document.write("<Script Language='javascript' SRC='http://page.com/somefile.jsp'>");
but I know that you will need to open and close the document, and I don't know how well that will mingle with the rest of your HTML page....

I don't see the problem personally with having the header file referenced in each page, does it cause some kind of conflict error having it loaded for each page?

Let me know how it turns out for you.
<!-- I dunno -->
<HTML>
<HEAD>
	<TITLE>Testing App</TITLE>
	<SCRIPT LANGUAGE="Javascript">
	if (top.location != location) {
	     /* In A Frame, Don't Load The Header File */
	} else {
	     /* Not In A Frame, Load The Header File */
	     document.open;
	     document.write("<SCRIPT LANGUAGE='Javascript' SRC='http://www.yourpage.com/file.js'>");
	     document.close;
	}
	</SCRIPT>
</HEAD>
<BODY BGCOLOR="#000000" TEXT="#FFFFFF">
Test
</BODY>
</HTML>
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:04 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC