views:

518

answers:

1

I have a page called "k.html" which is in domain A. This page will be used as an iframe by pages "a.html" in domain B, domain C, domain D, domain E.

I want to set the parent location in this "k.html":
Domain B's "a.html" page to Domain B's "b.html" page
Domain C's "a.html" page to Domain C's "b.html" page
Domain D's "a.html" page to Domain D's "b.html" page

I have tried

window.top.location = Domain B + "b.html";

It works. But I don't want to hardcode the "Domain B" in this situation.

What should I do?

A: 

You should be able to read (while not change) the location of the parent:

var par_host = parent.location.host;

However, I'm surprised, that your code works. I thought it should fall under the "same origin" policy.

Cheers,

Boldewyn
permission is denied in firefox
Billy
Yes, I thought so. But how can you set window.top.location, then? `window` does also belong to a different domain than your iframe, doesn't it?
Boldewyn