homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

How do I create a framebuster javascript from a subframe?

 7:36 pm on Oct 26, 2011 (gmt 0)

So my structure is like this:

Superframe.php (a frameset page)
toptenpercent.php (the content of the first frame)
bottomninetypercent.php (the content of the second frame)

What I would like to do is to create a javascript link on toptenpercent.php that when clicked only shows bottomninetypercent.php (that page in essence busts out of the frameset)

Anybody know how to do this with javascript?



 8:21 pm on Oct 26, 2011 (gmt 0)

Why in particular do you want to do it with JavaScript? Isn't it easier just to set the href target to _top?
This way it would also work for those that block JavaScript. I personally don't like sites that don't work properly without JavaScript enabled and usually will leave the site as soon as it doesn't work properly.

With JavaScript you would want to set top.document.location.href to your desired URL.


 9:27 pm on Oct 26, 2011 (gmt 0)

The link is in the subframe toptenpercent.php ... so I have to to _top, it will go to the main frameset page Superframe.php, which I don't want.

I want basically a sub frame to go to a sibling frame...possible, even without javascript?


 10:00 pm on Oct 26, 2011 (gmt 0)

Then you want parent.document.location.href


 2:15 pm on Oct 27, 2011 (gmt 0)

That will climb to the parent, which is I believe how I want to start...but then I have to climb back down to find the sibling...that's the trick. How does one frame reference a sibling frame with javasript, assuming they both share the same frameset parent page.


 4:53 pm on Oct 27, 2011 (gmt 0)

Have you tried (deprecated but should work) target="_blank"? Or if you want it to replace the whole page without a new window/tab, target="_top" should work. It shouldn't "go to" superframe, it should replace it - unless you've named it "_top". :-)


 9:01 pm on Oct 27, 2011 (gmt 0)

This might help you [yourhtmlsource.com...]

JAB Creations

 9:50 pm on Oct 27, 2011 (gmt 0)

You'll need to use try/catch, if someone else put your site in a frame you won't have permission to access top.window.

- John

try {var a = top.window.location.href;}
catch (err)
top.window.location = '';

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved