java script and Firefox

Discussion in 'JavaScript' started by login, Aug 20, 2007.

  1. #1
    Why is this not working in firefox, it works in IE and Opera.

    java script:

    function toggleMenu() {
    var oMenu = document.getElementById("item");
    if(oMenu.style.display == "none")
    oMenu.style.display = "block";
    else
    oMenu.style.display = "none";
    }


    html:

    <ul>
    <li onclick="toggleMenu();">Menu</li>
    <li id="item" style="display:none;">
    <ul>
    <li><a href="http://www.site1.com">site1</a></li>
    <li><a href="http://www.site2.com">site2</a></li>
    </ul>
    </li>
    </ul>

    Thanks.
     
    login, Aug 20, 2007 IP
  2. bogs

    bogs Active Member

    Messages:
    2,142
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    80
    #2
    have you tried ecma script? counter part of javascript.. its works like javascript too...
     
    bogs, Aug 20, 2007 IP
  3. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #3
    I have never heard about it. Will research.
     
    login, Aug 20, 2007 IP
  4. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #4
    It does work - something else in the document must be breaking it.
     
    Logic Ali, Aug 20, 2007 IP
  5. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Ok, thanks Ali. Will check that. Why isnt that something else breaking it in IE and Opera too?
     
    login, Aug 20, 2007 IP
  6. saadalgazzar

    saadalgazzar Peon

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    beacousr firefox is like the baby behind Internet explorer
     
    saadalgazzar, Aug 20, 2007 IP
  7. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Well, IE is the one not following the rules... all that special html fixes and so on.
     
    login, Aug 20, 2007 IP
  8. mjamesb

    mjamesb Member

    Messages:
    88
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #8
    It works for me too...So FF is not the issue. To anyone programming Javascript if you are not using FireBug then you are making coding so much harder on yourself than you have to. Just Google "FireBug".it is a free plugin for FF and works great. You can set break points, step through line by line..it will even show you what line the error is on. It has too many tools to mention but it has made writing JS much more effecient for me and many people I know.

    p.s. FF is superior to IE especially when performing complex client side scripts. The more complicated the slower IE renders.
     
    mjamesb, Aug 20, 2007 IP
  9. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #9
    I tried firebug and got this error:

    menusyk is not defined
    onclick(click clientX=0, clientY=0)

    Any idea what I should change?
     
    login, Aug 20, 2007 IP
  10. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #10
    Change whatever it is that is allowing a reference to be made to the non-existent object menusyk - or post more code.
     
    Logic Ali, Aug 21, 2007 IP
  11. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #11
    This is the site in question.
    www.altomhelse.info

    if you got the possibility, could you please take a quick look at it?
     
    login, Aug 21, 2007 IP
  12. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #12
    The code you presented is not the same as that on your site.

    <p onclick="toggleMenu(menusyk);">Sykdommer</p>
    Code (markup):
    Should be
    <p onclick="toggleMenu('menusyk');">Sykdommer</p>
    Code (markup):

    function toggleMenu(menusyk) {
    	var oMenu = document.getElementById("menusyk");
    	if(oMenu.style.display == "none")
    		oMenu.style.display = "block";
    	else
    		oMenu.style.display = "none";
    }
    Code (markup):
    Should be
    function toggleMenu(menusyk) {
    	var oMenu = document.getElementById(menusyk);
    	if(oMenu.style.display == "none")
    		oMenu.style.display = "block";
    	else
    		oMenu.style.display = "none";
    }
    Code (markup):
     
    Logic Ali, Aug 21, 2007 IP
  13. Divisive Cottonwood

    Divisive Cottonwood Peon

    Messages:
    1,674
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #13
    ecma script and javascript are one and the same
     
    Divisive Cottonwood, Aug 21, 2007 IP
  14. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #14
    Great Logic Ali, that works, Thanks for helping. Can I offer you a free PR5 link for some time?
     
    login, Aug 21, 2007 IP
  15. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #15
    lol. :p

    :)
     
    MMJ, Aug 22, 2007 IP