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 7 of 7

Thread: hide an iframe

  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hide an iframe

    how can i add a frame? I tried this but it doesn't work

    please help

    thanks,

    Code:
    <IFRAME id="frDocViewer" name="frDocViewer" height="75%" width="100%" frameborder="no" ></IFRAME>
    <script language="javascript">
    	function HideFrame(){
    		var fr = document.getElementById ("frDocViewer");
    		fr.style.display="none";
    	}
    
    </script>
    Last edited by jewel; 08-12-2005 at 03:04 AM.

  • #2
    New Coder
    Join Date
    Aug 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and also how to unhide?

    thanks

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <input type="button" value="Hide/Show" onclick="HideFrame();"  />
    <IFRAME id="frDocViewer" src="http://www.vicsjavascripts.org.uk" name="frDocViewer" height="75%" width="100%" frameborder="1" ></IFRAME>
    <script language="javascript">
    function HideFrame(){
     fr = document.getElementById ("frDocViewer");
     if (fr.style.display!='none'){
      fr.style.display="none";
     }
     else {
      fr.style.display="block";
     }
    }
    
    </script>
    </body>
    
    </html>

  • #4
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,696
    Thanks
    0
    Thanked 232 Times in 227 Posts
    Hi there jewel.

    and a warm welcome to these forums.

    Try it like this....
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>hide/show iframe</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
    
    <style type="text/css">
    <!--
    html,body {
         height:100%;
         background-color:#eef;
     }
    #click {
         width:300px;
         line-height:30px;
         font-family:verdana,arial,helvetica,sans-serif;
         font-size:16px;
         color:#666;
         text-align:center;
         background-color:#fff;
         border:3px double #666;
         cursor:pointer;
         margin:20px auto;
     }
    #frDocViewer {
         width:100%;
         height:75%;
     }
    -->
    </style>
    
    <script type="text/javascript">
    <!--
    function HideFrame() {
      var fr = document.getElementById ("frDocViewer");
    if(fr.style.display=="none") {
       fr.style.display="block";
    }
    else {
       fr.style.display="none";
      }
     }
    //-->
    </script>
    
    </head>
    <body>
    
    <div id="click" onclick="HideFrame()">hide/show iframe</div>
    
    
    <iframe id="frDocViewer" src="http://www.codingforums.com/showthread.php?t=65683" frameborder="1" ></iframe>
    
    
    </body>
    </html>
    coothead

  • #5
    Registered User
    Join Date
    Oct 2004
    Posts
    592
    Thanks
    0
    Thanked 1 Time in 1 Post
    So great and Nice.

  • #6
    New Coder
    Join Date
    Aug 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks everyone

  • #7
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to have variable height of frames (IE & FF)?

    How can I create multiple IFRAMES (or frames) on a page that have variable height?

    To illustarte the point think of it that I want a page that will have my menus on top, then a page (of indeterminate length) from abc.com and then another page from def.com, and so on...

    Please help!! Thanks!!
    --


  •  

    Posting Permissions

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