PDA

View Full Version : Always in frame - is this script right?


bacterozoid
11-30-2002, 07:12 PM
It works, but I've never used anything like this before, so I wasn't sure if it was done right.

<SCRIPT LANGUAGE="JavaScript">
if (top.location.href == window.location.href) {
window.document.location = "index.htm"
}
</SCRIPT>

...Where index.htm is the frameindex page. It simply checks the href, and if it matches (which it will if only one frame is being viewed) it sends you to the frame index page.

smeagol
11-30-2002, 08:14 PM
JavaScript Kit has a script that does this very thing. Just in case you want to see how it works, here's a link to it:

http://www.javascriptkit.com/script/script2/keepframes.shtml

I tested your code and it works fine for me.

Hope this helps.

bacterozoid
11-30-2002, 08:18 PM
Ah, neat. Instead of checking for the URLs to be the same, it simply checks if the page is in frames or not. I do suppose it wouldn't matter which one I use...but I think I'll use mine, since I actually wrote it myself. Thanks!

mhere
12-01-2002, 10:33 AM
this script not only send you to the frameset page but loads the requested page in the frameset using cookies:

www.peterbailey.net/js/superframes.js

the script is from peterbailey (known as beetle here)