Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: open

How do I create a framebuster javascript from a subframe?

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

5+ Year Member



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)

WebmasterWorld Senior Member 5+ Year Member



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)

5+ Year Member



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)

WebmasterWorld Senior Member 5+ Year Member



Then you want parent.document.location.href
2:15 pm on Oct 27, 2011 (gmt 0)

5+ Year Member



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)

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



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)

WebmasterWorld Senior Member 5+ Year Member



This might help you [yourhtmlsource.com...]
9:50 pm on Oct 27, 2011 (gmt 0)

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



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 = '';
}
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month