SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why can't I manipulate display:none in opera 6?

    The code below hides and shows the layer when you click the link, it works fine in IE and ns6, does anyone know why it doesn't work in opera 6, thanks for any suggestions.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" type="text/JavaScript">
    var layerOn = 1;
    
    function removeLayer() {
    	if (layerOn){
    		document.getElementById('layer1').style.display = 'none';
    		layerOn = null;
    	} else {
    		document.getElementById('layer1').style.display = 'block';
    		layerOn = 1;
    	}
    }
    </script>
    
    <style type="text/css">
    <!--
    #layer1 {
    	position:relative;
    	left:50px;
    	width:150px;
    	height:150px;
    	background-color:#ff0000;
    	display:block;
    	color:#ffffff;
    	padding:15px;
    }
    body {
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 11px;
    	color: #666666;
    	margin-left:40px;
    }
    -->
    </style>
    </head>
    <body>
    
    <br /><br />
    <a href="#" onclick="removeLayer();return false">click here to show or hide the layer</a>
    <br /><br /><br />
    <div id="layer1">My Layer</div>
    
    </body>
    </html>

  2. #2
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opera 6 (and below) have... um... suboptimal DOM support. Opera 7 will apparently be much better.

    I messed about with stuff like this a few months back, I'll try to look at the script when I'm in the same building* tomorrow and see if I can be more helpful.

    *Though I wrote the script in quesion in about February, it's still not live, so it only exists on internal development servers...

  3. #3
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, apologies for the delay.

    This page:
    http://www.opera.com/docs/specs/
    Gives a comprehensive list of what is and isn't supported by Opera. As you will see about half way down the page, support for javascript manipulation of the DOM is pretty thin. Opera have indicated that version 7 will be much better.

    The closest you've got for now is to play with visibility, e.g.
    Code:
    document.getElementById('layer1').style.visibility = "hidden";
    [...]
    document.getElementById('layer1').style.visibility = "visible";
    Unfortunately, the element will still occupy space on the page, though if it's an absolutely-positioned div, this shouldn't be a problem.

    My script was using absolutely positioned divs, so this was good enough for me.

  4. #4
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply blufive, unfortunately I can't use visibility instead, because I am using it to create a simple collapsable menu, so I have to use relative positioning. It looks like opera users will just have to suffer the uncollapsed version.

  5. #5
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, for that kind of thing, you've had it, I think. Roll on opera 7...


Bookmarks

Posting Permissions

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