www.webdeveloper.com
Results 1 to 5 of 5

Thread: Changing visibility of Iframe

  1. #1
    Join Date
    Jan 2009
    Posts
    3

    Question Changing visibility of Iframe

    Hey world! I'm REALLY new to javascript and i wanted to make a simple script that shows or hides an Iframe. Here's an example of what i think would work but doesn't:


    Code:
    <a href="javascript:showHide()">Show or Hide Frame</a>
    <iframe src="http://www.google.com" name="google" id="google" style="visibility:visible"></iframe>
    <script type="text/javascript">
    function showHide(){
       if (document.getElementById("google").style.visibility == "visible"){
          document.getElementById("google").style.visibility == "hidden";
       } else if (document.getElementById("google").style.visibility == "hidden"){
          document.getElementById("google").style.visibility == "visible";
       }
    }
    </script>
    Can someone please tell me what's wrong???

  2. #2
    Join Date
    Feb 2008
    Posts
    1,666
    You have errors in your script (double equal signs for assignment operations), but the fact that the IFRAME source is an external domain may make it impossible for you to control the IFRAME via JavaScript.

  3. #3
    Join Date
    Jan 2009
    Posts
    3

    Question Div?

    How about if i put a div tag around the iframe and access the div thru javascript instead of the iframe?

  4. #4
    Join Date
    Feb 2008
    Posts
    1,666
    Sounds good.

  5. #5
    Join Date
    Jan 2009
    Posts
    3

    nope

    still doesnt work, can you fix errors in my script?



    edited: nevermind...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles