hiding (not closing) an Iframe from self

N

Nathan White

I want to be able to hide an iframe but I need to be able to activate
this from the iframe itself.

This works most of the time but I it runs into issue when the domains
don't exactly match I get the following error in Firefox:

Error: uncaught exception: Permission denied to get propert
HTMLIFrameElement.style

I have tried:

document.defaultView.frameElement.style.display = 'none';

and

parent.document.getElementById('theIframeElement').style.display='none';

Is there a work around?
 
M

Martin Honnen

Nathan said:
I want to be able to hide an iframe but I need to be able to activate
this from the iframe itself.

This works most of the time but I it runs into issue when the domains
don't exactly match I get the following error in Firefox:

Well if the <iframe> element is in a document loaded from a different
origin then indeed the document in the iframe can't access or manipulate
stuff in the parent document. That is the same origin policy.

The only solution the same origin policy allows is if you have e.g. one
document from host1.example.com and one from host2.example.com, then you
can set
document.domain = 'example.com'
in both documents before trying any cross document access.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top