Javascript and Menus using styles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Disco

    #1

    Javascript and Menus using styles

    Hi,

    Does anybody know how to make this piece of javascript (below) work in
    netscape? This only works in IE (I have only tried 5.5 and 6). I would
    like to know how to make this work exactly the same way in Netscape.

    Thanks very much...


    <html>
    <head>
    <script language="JavaS cript">
    function doit(pTable){
    if (document.all[pTable].style.display == "none"){
    document.all[pTable].style.display = "block";
    }
    else{
    document.all[pTable].style.display = "none";
    }
    }
    </script>
    </head>

    <body>
    <div class='mainmenu '><a href="#" onclick="doit(' Group1');return
    false;">Menu One</a></div>
    <div style="display: none;" id="Group1" name="Group1">
    <a href="#">Item 1.1</a><br />
    <a href="#">Item 1.2</a><br />
    <a href="#">Item 1.3</a>
    </div>
    <br />
    <div class='mainmenu '><a href="#" onclick="doit(' Group2');return
    false;">Menu Two</a></div>
    <div style="display: none;" id="Group2" name="Group2">
    <a href="#">Item 2.1</a><br />
    <a href="#">Item 2.2</a><br />
    <a href="#">Item 2.3</a>
    </div>
    </body>
    </html>






  • Sean Jorden

    #2
    Re: Javascript and Menus using styles

    "Disco" <discooctopus@y ahoo.com> wrote in news:86h5b.1025 $U74.61328
    @news.optus.net .au:
    [color=blue]
    > Hi,
    >
    > Does anybody know how to make this piece of javascript (below) work in
    > netscape? This only works in IE (I have only tried 5.5 and 6). I would
    > like to know how to make this work exactly the same way in Netscape.
    >
    > Thanks very much...
    >[/color]


    use document.getEle mentById(pTable ) instead of document.all[pTable]

    document.all is microsoft specific and document.getEle mentById is the
    standards way supported by modern browsers. IE4, I believe, is the only
    browser that supports document.all but not document.getEle mentById.




    --
    In theory there is no difference between theory and practice. In practice
    there is. - YB

    Comment

    Working...