Java script menu

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

    Java script menu


    Can anyone see whats the problem here. Menus wont open..Works fine i
    IE, but none else..
    I also need the menus to shut automatically when the next opens..
    possibly with a java script function?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD DHTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Meny</title>
    <meta http-equiv="Content-Type" content="text/html
    charset=iso-8859-1">
    <link rel="stylesheet " href="Styleshee t_lankar.css" type="text/css">

    <script language="JavaS cript">

    function visadolj1(obj) {

    if(obj.style.di splay=='none') {
    obj.style.displ ay='block'
    var x = 1
    }
    else {obj.style.disp lay='none'
    var x = 2
    }
    }

    </script>
    </head>

    <body>

    <TABLE width="149" border=0 align="center" cellPadding=0>
    <TBODY>
    <TR>
    <TD rowspan="Yes">

    <div id="huvud" onclick=
    "visadolj1(u1)" >
    <p class="medium"> TEXT main<br><br>
    </div>

    <div id="u1" style="display: none">
    <a href="Something .htm" target="main" class="link1">T EXT<br>
    <br></a>

    <a href="Something .htm" target="main" class="link1">T EXT<br><br></a>

    <a href="Something .htm" target="main" class="link1">T EXTbr><br>
    </a></div>


    </TD>
    </TR>
    </TBODY>
    </TABLE>
    </body>
    </html

    --
    bergarat
    -----------------------------------------------------------------------
    bergarath's Profile: http://www.highdots.com/forums/member.php?userid=9
    View this thread: http://www.highdots.com/forums/showthread.php?t=133435

  • Richard Cornford

    #2
    Re: Java script menu

    bergarath wrote:
    <snip>[color=blue]
    > ... Works fine in
    > IE, but none else..[/color]
    <snip>[color=blue]
    > function visadolj1(obj) {
    >
    > if(obj.style.di splay=='none') {
    > obj.style.displ ay='block'
    > var x = 1
    > }
    > else {obj.style.disp lay='none'
    > var x = 2
    > }
    > }[/color]
    <snip>[color=blue]
    > <div id="huvud" onclick=
    > "visadolj1(u1)" >
    > <p class="medium"> TEXT main<br><br>
    > </div>
    >
    > <div id="u1" style="display: none">[/color]
    <snip>

    IE has a habit of making IDed elements available by reference as global
    variables with names that correspond with the element's ID attribute
    value. When the onclick handler is executed the Identifier 'u1' is
    resolved against the scope chain and IE finds that global reference and
    passes a reference to the DOM eleme3nt to the - visadolj1 - function.

    Browsers that do not provide such global references cannot resolve the
    identifier and so pass the Undefined value to the function call. This is
    covered in the FAQ, along with reliable approaches to referring to IDed
    DOM elements.

    Richard.


    Comment

    Working...