SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Layer .style.display=block not responding in Mac Opera

    Hello,

    I'm trying to toggle some layers using the layer.style.display = block/ layer.style.display=none method and it works fine in ever browser except Mac Opera, Mac/Windows Netscape 4.

    I know these browsers handle layers differently and I've tried to use this method w/ no effect:

    layer.style.visibility = 'visible'; layer.style.visibility = 'visible';

    Here's the code I'm using that works in every browser:
    Code:
    function toggle_layers( this_div ) 
    {
          doc = document.getElementsByTagName('div');		
    
           for( var i = 0; i < doc.length; i ++ ) 
           {		   	    
                  if( this_div == doc[i].id )
                  {
    	              doc[i].style.display = 'block';  
                  }
                  else
                  {
                          doc[i].style.display = 'none';  
                  }
          }
    }
    thanks for any help you can give me.

    Clem C
    Last edited by clem_c_rock; Nov 30, 2006 at 07:51.

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Clem,

    I don't have a Mac, but that technique should work (but not in NN4). What version of Mac Opera are you using? Perhaps if we could look at your entire page we might spot something.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using Mac Opera version 6.03.

    This is the file I am working on:

    http://peopledesigns.com/layer_test/start_test_pg2.php#

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using Mac Opera version 6.03.
    I'm not surprised then. Why not upgrade to a later version?

    Sorry, I don't have time to look at your page right now - but I will as soon as I can.


  5. #5
    SitePoint Zealot yacka's Avatar
    Join Date
    Aug 2006
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That code you posted is missing a closing brace in the for loop. I can't test on Mac Opera 6, but the (fixed) code does work in Windows Opera 9.

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're correct on the missing brace - an oversite when I posted this. The code wasn't like this in my live example so I know that's not and issue.

    Fixed now

  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Clem,

    I'll be honest with you, that page has many problems.

    The first thing you need to do is to look at the validator results.

  8. #8
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow - I've always used Mozilla's javascript console for debugging but this thing is great.

    Still - I fixed the errors that could possibley affect the script working in Opera and they don't have any bearing to the original question.

    Thanks big time for the like to the validator - what a fine tool!

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Older versions of Opera such as version 6 were somewhat behind the other browsers in their support of things like changing between display:none and display:block. The lastes Opera version 9 is if anything ahead of the other browsers in what it supports.

    The only reason for running Opera 6 on a Mac is if you have an old Mac that is running OS9 where that browser and iCab are the only browsers still supported.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good info, felgall - thanks.

    Clem, I'm sorry but my suggestion is to throw it out and start over. I have put together a template for you to try out. It uses a CSS layout and an unobtrusive Javascript UL menu that can have unlimited levels. Be sure to view the template with Javascript disabled as well as enabled.

    If you are interested in using it, let me know and I'll beef it up a little.

  11. #11
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike - I can't thank you enough for going to all the trouble in making that mockup for me. I already learned a lot from looking @ your code.

    totally interested in seeing how this all works - looks like a winner.

    Thanks again - you have gone way past being helpfull.

    Cheers!

  12. #12
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Clem,

    You are very welcome. I'm glad you like it

    I've made some updates to that menu - and I've moved it out of that 'test' folder. Here's the new link. Check it now and then because I may make updates to it. If you run into any problems we'll be here

  13. #13
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opera 6 didn't actually even have proper DOM support (introduced in version 7), so once you rendered the page there was not much to do to change it. Bit like Netscape 4 (though not so horrible).

  14. #14
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bit like Netscape 4 (though not so horrible)

  15. #15
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike - this example is great and is a totally new approach that I haven't thought of -big chunk of learning you just gave me.

    One thing I noticed in Mac Opera 6 is that when the page loads, all the divs are expanded (styles set to block).

    Seems to me that if they load that way they should respond to some code tweak.

    Either that or this concept just isn't possible in Mac Opera 6.

    I'm not ready to give up yet being the stubborn ******* that I am.


    Thanks again-you rule!

  16. #16
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why even bother with Opera 6 for Mac? I doubt there is anybody out there using O6 as their main browser.

  17. #17
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with Pepe about not testing in O6 - but the effect you're describing will be seen by any browser, so add the following as the first line of Javascript in the script element in the head:
    Code:
    document.write("<style type='text/css'>.clsSubMenuUL{display:none;}<\/style>");

  18. #18
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Pepejeria
    Why even bother with Opera 6 for Mac? I doubt there is anybody out there using O6 as their main browser.
    Well Opera 6 and iCab are the only two browsers still officially supported on OS9 so for anyone running an old Mac there isn't much choice (although I suppose more are probably sill running the long deceased and no longer supported IE5)

    Opera didn't really start to get close to properly supporting the DOM until version 7. Maybe iCab has better support for the DOM on OS9 - have you tested that?
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  19. #19
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    iCab 3 is much, much better than Opera 6.

    I haven't tested it on OS9, but I expect that both the Classic-OS and OS-X versions would handle things the same.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  20. #20
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike,

    This worked great for closing all divs when the page loaded but once the divs are closed, they won't open again.

    ( document.write("<style type='text/css'>.clsSubMenuUL{display:none;}<\/style>"); )


    Thanks again,
    you rule!

  21. #21
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Clem,

    I've made quite a few enhancements to the menu. Check it out.

    Give us a link to your page - there's nothing at your previous link.

  22. #22
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's looking completely awesome! I hope you're doing this more for yourself than me because if you're doing it to help me - I should cut you a check right now.

    Oh yeah - we're going through a server change right now so the link is IP'd:

    http://208.51.26.176/layer_test/start_test_pg2.php

    I just hate to say this but it still doesn't do the style='block' behavior in Mac Opera 6 but - as we all have conceded -it doesn't matter at all except for the fine sense of knowlege and kicking some code ***!

    Thanks again!

  23. #23
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks :-)

    Other people have asked for a variety of features in an object like this, so I'm just trying to find a good stopping point before I leave it.

    I'm sure Opera 6 did not support the 'display' property.

    Is that the right link to your current page?

  24. #24
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah - this is a very cool navigation system and could have many uses. The fun could really start if you made the links dynamically drawn from a database and merged w/ some web programming language.

    That link is correct.

    It is weird the menu displayed as completely open until you added that block of code at the top (document.write("<style type='text/css'>.clsSubMenuUL{display:none;}<\/style>").

    One would think that it would react to a display:block as well.

  25. #25
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The fun could really start if you made the links dynamically drawn from a database and merged w/ some web programming language.
    That could be done with PHP or some other server-side script. It really would not affect this client-side script.

    That link is correct.
    For me that link goes to your page using tables for layout and the previous menu you were using.


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
  •