Refresh url from inside iFrame

is it possible for javascript inside the iFrame to update the url (hash) of the parent page (and retrieve it) Does it have any permissions?

To clarify, I do not have hosting for this domain, I can configure the iframe. I also cannot use the DNS configuration to display this page due to the limitations of my hoster. I also cannot transfer the domain to them in order to do this work, because my clients want to maintain control over the domain.

Thank you for your help!

+3
source share
3 answers

If the page <iframe>is within the same domain, perhaps yes. Otherwise, you will not get access to the parent page due to restrictions between domains.

URL- :

top.location.href = 'http://www.example.com';
+2

- , , iframe.

+2

, .

Your script only works in the context of this iframe. If you try, for example,

var loc = document.location;

You will see what I mean.

One solution is that when you give the other side your iframe, you should add a script to the fact that you can do whatever you want, because it works on your domain. Maybe dynamically create the source of your iframe and stuff.

+1
source

All Articles