View Full Version : Hide DIV within iFrame

07-30-2010, 02:59 PM
I want to be able to hide a DIV within an iframe from the parent document. The usual document.getElementById('element').style.display="none"; doesn't work as I can't point to elements within the iframe with it. What do I need to add to make it look within the iframe and not the parent document?

Many thanks in advance.

07-30-2010, 03:11 PM
You need to perform a complete reference. Suppose your iframe element has an id, say id="myIframe". Now:

var myElementInIframe=document.getElementById('myIframe').contentWindow.document.getElementById('element ');

07-30-2010, 06:44 PM
Great, thank you very much.