Break Outta Frames!

Journal started Feb 7, 2002


Break out of frames!

I just did something nifty with my top page! I happen to rabidly despise those sites that think they can keep their advertising info on a top frame while kindly directing you to surf the web in the bottom frame. Not only does it make the window smaller, but it insinuates that the advert site gets credit for MY page. I like frames; they're useful. But frames to another person's page is borderline illegal, and certainly not very nice.

Since most frame supporting browsers support Javascript, and those that have frames but no javascript can still use the "target" attribute, I added this to my top page:

<SCRIPT LANGUAGE="JavaScript">
/*<!-- <![CDATA[ */
//Learned from http://www.boogiejack.com/howx009.html
//Boogiejack's Web Depot
var ischanged = 0;
function changePage() {
	if(!ischanged) {
		ischanged = 1;
		if (window != top || self.parent.frames.length != 0)
			top.location.href = location.href;
	}
}
changePage();
window.onload = changePage
setTimeout ("changePage()", 3000);
// ]]> -->
</SCRIPT>
</head>
...
<body>
...
<a href="" target="_top">Break</a> out of frames!
To a reasonable reliability, it will _automatically_ reload my page destroying all annoying border-frames. If not, you can click the Break link.

Note: Make sure to put the automatic javascript code in the HEAD section, otherwise you'll waste time loading the document the first time.

Update: Inline javascript sucks, so do this instead:

<script type="text/javascript" src="breakframes.js" charset="utf-8"><script>
...
</head>
...
<body>
...
<a href="" target="_top">Break</a> out of frames!
Also see here for the external javascript file.

Also, try here to check if the code is working. If it is, you should just see this journal again.


Comment
Index
Previous (What is the Meaning of Life?)
Next (All Those Caught with Closed Minds will Have Them Opened Forcibly)

(cc) some rights reserved