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 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Dynamically Hide a frame in NS 7.0 and IE 6.0

    My webpage consists of 3 frames(top, left and main). On event onclick in "main" I want to control the show /hide of "left" frame. The javascript has to work in both NS7.0 and IE6.0. A solution with sample javascript will be of great help. The HTML for mywebpage is given below.

    <html> <head> <title>My webpage</title> </head>
    <frameset rows="50,*" > <frame name="Top " src="Top.html" marginwidth="0" marginheight="0" noresize scrolling="no">
    < FRAMESET COLS= "200,*" > <FRAME name="Left" src="left.html" marginwidth="5" marginheight="5" scrolling="auto" > <FRAME name="main" src="main.html" marginwidth="5" marginheight="5" scrolling="auto" > </FRAMESET>
    </FRAMESET>
    </html>

  • #2
    Regular Coder
    Join Date
    Mar 2003
    Posts
    176
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this:


    Code:
    <html> 
    <head> 
    <title>My webpage</title> 
    </head> 
    <frameset rows="50,*" > 
    <frame name="top" src="Top.html" marginwidth="0" marginheight="0" noresize scrolling="no"> 
    <frame name="main" src="main.html" marginwidth="5" marginheight="5" scrolling="auto" > 
    </frameset> 
    </html>
    ...top.html...

    Code:
    <html>
    <head>
    <title>Top</title>
    </head>
    <body bgcolor="#EEEEEE">
    </body>
    </html>
    ...left.html...
    Code:
    <html>
    <head>
    <title>Left</title>
    </head>
    <body bgcolor="#EEEEEE">
    <div style="height:700px;">Left</div>
    </body>
    </html>
    ...main.html...

    Code:
    <html>
    <head>
    <title>Main</title>
    <script language="jav&#97;script" type="text/jav&#97;script">
    <!--
    function toggleFrame(){
    var pos = document.getElementById('pageDiv').style.left 
    	if(pos=="10px"){
    		document.getElementById('pageDiv').style.left = 210
    		document.getElementById('bodyframe').style.visibility = "visible"
    		document.getElementById('lnk').innerHTML = "Hide Frame"
    	} else if(pos == "210px"){
    		document.getElementById('pageDiv').style.left = 10
    		document.getElementById('bodyframe').style.visibility = "hidden"
    		document.getElementById('lnk').innerHTML = "Show Frame"
    	}
    		
    }
    //-->
    </script>
    </head>
    <body>
    <div id="bodyframe" style="visibility:visible">
    	<iframe id="left" SRC="left.html" frameborder="0"
    	style="position:absolute; left:0; top:0; width:200; height:400">
    	</iframe>
    </div>
    <div id="pageDiv" style="position:absolute; left:210px; top:0px;">
    <a id="lnk" href="jav&#97;script: void toggleFrame()">Hide Frame</a>
    </div>
    </body>
    </html>
    It should work in the desired browsers.
    Last edited by HairyTeeth; 04-01-2003 at 06:10 AM.

  • #3
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    The above solution uses iframes which I can not use due to some issues with my web pages. Is it not possible to use normal frames to acheive this ?

  • #4
    New Coder
    Join Date
    Feb 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know if this is the best solution but you can use a simple blank page to load in the left frame when you want to hide the left frame content.

  • #5
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Blank page is not a good solution for me as my intesion is to gain more screen space for my main frame by hiding the left frame.

  • #6
    Regular Coder
    Join Date
    Sep 2002
    Location
    Surrey, UK
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts
    could try:
    parent.cols="0,*";// to hide
    parent.cols="200,*";// to show

  • #7
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Above solution doesn't work for NS7.0 !

  • #8
    Regular Coder
    Join Date
    Mar 2003
    Posts
    176
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How about re-writing the entire frameset (without or without left.html) and reloading. For example:

    Code:
    function noLeftFrame(){
    document.write("<frameset>")
    document.write("<frame src='top.html'>)
    document.write("<frame src='main.html')
    document.write("</frameset")
    document.close()
    location.reload()
    }
    
    function haveLeftFrame(){
    document.write("<frameset>")
    document.write("<frame src='top.html'>)
    document.write("<frameset>")
    document.write("<frame src='left.html')
    document.write("<frame src='main.html')
    document.write("</frameset")
    document.write("</frameset")
    document.close()
    location.reload()
    }
    }
    No idea if it works though. Also, using the reload will clear everything in the browser's memory (eg form data).
    Last edited by HairyTeeth; 04-01-2003 at 07:39 PM.

  • #9
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This will work but will have some serious disadvanteges llisted below. So I will not be able to use this solution

    1)Reload clears the previuos state of the pages. This is important for me because my "main" frame is actually a target for Menu links in the left frame.

    2)The user can not save and print the pages. If try to save/print the page, it appers as blank.

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Using frames has some serious disadvantages... I would use include files or something instead to completely avoid these problems (among others).
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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