0

I have the following problem:

I open an url in an iframe:

<iframe src="" name="framenamex" id="idframex"

<a href="urlsamedomainx" target="framenamex"...

but then when I want to hide the iframe from within the iframe:

javascript:parent.document.getElementById('idframex').style.visibility='hidden'

nothing happens, it seems like the iframe has no parent because when I call the parent.location or window.top.location I get nothing

please help. thanks in advance.

1 Answers1

1

For security reasons, this isn't generally possible, otherwise any iframe would be able to access the page it is in and steal user data or other stuff.

If you control both the iframe code as well as the page code, you can get them to communicate. There are many tutorials and libraries to assist with this... here's one: http://viget.com/extend/using-javascript-postmessage-to-talk-to-iframes

Hamza Kubba
  • 2,259
  • 14
  • 12