Peter
Peter

Reputation: 728

top.window.location internet explorer permission denied error

I want to do redirect a page from an iframe, specifically i want to redirect the top page from an iframe.

so im using:

top.window.location = 'http://xxx'

Its working fine in mozzila or chrome, but in ie i get: permission denied error. I found some infor that this is cross-domain scription problem:

http://www.mombu.com/microsoft/microsoft/t-ie-shows-permission-denied-javascript-error-on-toplocationhre-4565452-last.html

i i dont know how to do it any other way - to redirect parent window to some url from a iframe, wich sits on different url (obviously)

thank for your help...

Upvotes: 0

Views: 4721

Answers (2)

Anderson
Anderson

Reputation: 87

I had the same problem, using:

top.window.location= "http://www.google.com";

and I changed it to:

window.parent.location = "http://www.google.com";

Which solved it for me.

Upvotes: 1

KateYoak
KateYoak

Reputation: 1731

There is a way to redirect the parent frame cross-domain. It's a trick, actually. :-) It will work if you have access to the server hosting the parent frame.

Inside your frame, create a child frame, too small to be seen, from the same domain as the parent frame. Your little child frame is allowed to change the parent document's location.

Parent:

<iframe src="http://other-domain/doc.html"></iframe>

doc.html

All the stuff from the document...
<iframe width="0" height="0" src="http://original-domain/trick.html"></iframe>

trick.html

<script>
    window.location.replace("http://xxx");
</script>

Upvotes: 1

Related Questions