views:

256

answers:

1

Hi,

I have a aspx page that is inside a frame. I want to redirect to a new page but before that page loads, break out of the frame. I was using this js code

window.onload = TimeOutRedirect;
function TimeOutRedirect()
{
    try
    {
    if (self.parent.frames.length != 0)
    self.parent.location=document.location;
    }
    catch (Exception) {}
}

This works but it waits until the page loads so you can see the page in the frame before it breaks out.

I tried using another page as a middle man but I can't redirect after page loads.

+2  A: 

See Jeff's post at http://www.codinghorror.com/blog/archives/001277.html

Basically, you can try and bust out of their frames.... and they can try to bust your frame busting code. It really depends on how determined the framer is.

To quote:

What's really scary is that near as I can tell, there is no solution. Due to cross-domain JavaScript security restrictions, it is almost impossible for the framed site to block or interfere with the parent page's evil JavaScript that is intentionally and aggressively blocking the framebusting.

If an evil website decides it's going to frame your website, you will be framed. Period. Frame-busting is nothing more than a false sense of security; it doesn't work.

Jonathan Fingland