Welcome to Jokes2000. Tips for improving your website: Graphic, HTML and javascript A fine collection of cartoons Jokes jokes jokes - get a good laugh Joke of the day and mailing list Table of contents
Jokes2000.com Jokes2000.com
 

Escape Frames Automatically Up One Level.

Sometimes sites link to your site by loading your pages within their frames. It is not nice to have another site framing your site -- especially if they are displaying banner ads etc. If your site uses frames, some browsers may crash and your javascripts referring to the top-frame will seize to function.

If your site does not use frames, you can break out by including the following javascript in the top of all your pages. Preferable within <head> and </head> element. If your site does use frames, include the javascript only in the frameset index-file (the file containing the <frameset> elements):

<script language=javascript type="text/javascript">
<!--
if (parent.frames.length) 
  top.location.href= document.location;	
// -->
</script>


Note that document.location is a synonym for document.URL. Netscape will remove document.location in a future version of their browser. However MSIE3 only understands document.location.

The script is not without any problems. When a site frames your site, a small problem related to the back-button, will occur in these browsers: Netscape 2, 3 and MSIE 3, 4. The problem is, that the user cannot get back to the site who framed your site. The problem is not present in Netscape 4.

If your site uses frames, you can use an alternative method to break out. This method does not have the back-button problem. In the following, we call the normal frameset index-file of your site index.php3. Make a copy of index.php3 and call it frameset.htm. Put the following javascript in the <head> and </head> element of index.php3 (but not in frameset.htm).

<script language=javascript type="text/javascript">
<!--
if (parent.frames.length) 
{ window.open("frameset.htm", "MySiteWindow");
  location.href= "escaped.htm";	
}
// -->
</script>


When another site frames your site, your site will pop-up in a new browser-window. The file escaped.htm will be displayed in the frame of the other site. It should contain some simple text like: Thanks for visiting our site..


Affiliate Sites: Funny Videos | Fight Videos | Free Arcade Games


welcome | cartoons | jokes | daily jokes | sitemap | search | feedback | what's new

Copyright © 1997-2007 Real Comedy Inc.