Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update URL from inside an iFrame

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

To further explain, I have no hosting for this domain, I can only set up an Iframe. I also cannot use a DNS config to get that page to display because of limitations of my hoster. I also cannot transfer the domain to them to make that work because my clients wants to keep control of the domain.

Thank you for your help!

like image 698
cmplieger Avatar asked Apr 21 '26 09:04

cmplieger


2 Answers

If the <iframe> page is within the same domain, probably yes. Otherwise you don't get access to the parent page due to cross-domain restrictions.

You can change the URL of the parent page though:

top.location.href = 'http://www.example.com';
like image 101
Ja͢ck Avatar answered Apr 23 '26 00:04

Ja͢ck


due to security constraints you will not be able to access properties of the parent window IF the domain,port or protocol is different than the one in the iframe.

like image 42
richardtz Avatar answered Apr 22 '26 23:04

richardtz