What the title says. How can it be done? I want them to click a hyperlink which, using javascript or any other methods, would redirect the parent window to a new url.
+11
A:
window.top.location.href = "http://site.com";
window.top
refers to the window object of the page at the top of the frames hierarchy.
Luca Matteis
2009-02-24 06:26:55
window.top.location.href property can't be updated from Iframe, it throws access denied execption. It can only be executed when you are testing on localhost
Ummar
2010-06-05 15:40:16
+1
A:
or an alternative is the following (using document object)
parent.document.location.href = "http://site.com";
Chandan .
2009-02-24 10:19:06
+1
A:
window.top.location.href = "http://www.site.com";
As stated previously, will redirect the parent iframe. One thing to bare in mind is that both the website, and the site contained in the iframe need to be in the same domain for this to work, or you'll get an access denied exception.
So, if the site is 'www.site.com', and the iframe is 'iframe.site.com', in both pages you'll need to put:
document.domain = "site.com"
MIP
2010-07-07 08:41:58