TAGS :Viewed: 13 - Published at: a few seconds ago
[ Redirect parent iFrame from nested iFrame ]
I saw this question on redirection iFrames Redirect parent window from an iframe action but the answer addressed redirecting the entire page.
The redirect was using:
window.top.location.href = "http://www.example.com";
Is there a way to redirect nested iFrames?
ie.
<browser>
<iframe src="someSrc">
<!--iFrame page-->
<iframe src="nestedSrc"></iframe>
</iframe>
</browser>
So from the nestedSrc
redirect someSrc
to another page instead of redirecting the browser page.
Answer 1
If you have access to the parent iframe's domain, you can simply redirect it using:
window.parent.location = 'http://new.location.com';
Small parent
/top
example
<Browser>
<iframe1>
<iframe2>
</iframe2>
</iframe1>
</Browser>
Inside iframe2 the following are true:
window.parent.parent == window.top // true
window.parent == window.top.frames[0] // true
Note: the following example presumes browser
and iframe
1
& 2
all are from the same domain