Forum Moderators: open

Message Too Old, No Replies

pls add to: "handy, generic javascript coding" thread

force a frameset around an i-frame

         

robjammin

8:18 pm on Apr 16, 2007 (gmt 0)

10+ Year Member


just modded something i found in that thread, and thought this would work better. This one works on the index page, making that the "master" page, described in tedster's
"FORCE MANY PAGES INTO FRAMES with one simple script" post.

http://www.webmasterworld.com/forum91/567.htm

here's the code to go on content page headers:

<script language="JavaScript" type="text/javascript">
badURL = document.URL
passpage = badURL.substring(badURL.lastIndexOf("/")+1, badURL.length)
if (top.location == self.location)
{
location.replace("index.php?" + passpage);
}
</script>

and here's the write code that writes the i-frame code into wherever you want it.

<script language="JavaScript" type="text/javascript">

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

if (contentURL!= origURL)
document.write('<iframe src=\"' + contentURL + '\" name="main" width="666" height="413" frameborder="0"></iframe>') ;
else
document.write('<iframe src="main.php" name="main" width="666" height="413" frameborder="0"></iframe>') ;
</script>

So it'll send it to a default page if this is indeed your index page you are working with, as in my case.

Dabrowski

8:41 pm on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



robjammin, if what you're trying to achieve is a frame-puller, I have one I wrote. It supports multiple nesting of iframes, and preserves the browser's back button.

Anyone who wants it send me a sticky and I'll send it to you.