Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    39
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Hide DIV within iFrame

    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.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    You need to perform a complete reference. Suppose your iframe element has an id, say id="myIframe". Now:
    Code:
    var myElementInIframe=document.getElementById('myIframe').contentWindow.document.getElementById('element');
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • Users who have thanked Kor for this post:

    daved2424 (07-30-2010)

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    39
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Great, thank you very much.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •