homepage Welcome to WebmasterWorld Guest from 54.166.255.168
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?
smithaa02

5+ Year Member



 
Msg#: 4379718 posted 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?

 

Dijkgraaf

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4379718 posted 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.

smithaa02

5+ Year Member



 
Msg#: 4379718 posted 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?

Dijkgraaf

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4379718 posted 10:00 pm on Oct 26, 2011 (gmt 0)

Then you want parent.document.location.href

smithaa02

5+ Year Member



 
Msg#: 4379718 posted 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.

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4379718 posted 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". :-)

Dijkgraaf

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4379718 posted 9:01 pm on Oct 27, 2011 (gmt 0)

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

JAB Creations

WebmasterWorld Senior Member jab_creations us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4379718 posted 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