• Hi:-
    I am working on a new site (not yet live) that includes some JavaScript menus where I had a show sections of HTML. The menus work fine in IE but don’t in Firefox. I saw that I was using document.all in my scripts. I substituted getElementById(), and the menus started to work a little, e.g. I got partial function.
    I used the Firefox error console to view the message which was document.getElementByID(subMenuCellA) is null.
    I am familiar with this message in IE. Normally it means I have made a typo or do not have unique names. But, if this was the problem, then the script wouldn’t work in IE either. However, it works fine.
    I thought maybe Firefox doesn’t like display:block type of features. However, I have a similar piece of code in another area and it works fine. So I am perplexed.
    I checked the Firefox website (that led me around in circles).
    Is there a resource somewhere that identifies stuff that doesn’t work in Firefox? Can anyone see what is wrong?

    The first two functions work:

    function processMenu(menuItem)
    {
    reinitMenu();

    menuChoice = “parent” + menuItem;
    document.getElementById(menuChoice).style.display = ‘block’;
    menuTD = “menu” + menuItem;
    document.getElementById(menuTD).className = ‘selected’;

    processSubMenu(‘1’);
    processSubMenu2(‘1’);
    processSubMenu3(‘1’);

    }

    function reinitMenu()
    {

    for (ctr=1;ctr<6;ctr++)
    {
    menuPoint = “parent” + ctr;
    document.getElementById(menuPoint).style.display = ‘none’; //hide all div sections
    menuCell = “menu” + ctr;
    document.getElementById(menuCell).className = ‘unselected’; //reset styles to unselected
    }
    }

    Here are the second two functions do not work, although they are similarly coded to the functions above.

    function processSubMenu(menuItem)
    {
    reinitSubMenu();

    subMenuChoiceA = “serviceChild” + menuItem;
    document.getElementById(subMenuChoiceA).style.display = ‘block’;
    subMenuIconA = “icon” + menuItem;
    document.getElementById(subMenuIconA).src = ‘images/iconLeftnavSelected.png’;
    document.getElementById(subMenuIconA).alt = ‘Current menu item’;

    }

    function reinitSubMenu()
    {
    for (ctr=1;ctr<6;ctr++)
    {
    subMenuPointA = “serviceChild” + ctr;
    document.getElementById(subMenuPointA).style.display = ‘none’; //hide all div sections
    subMenuCellA = “icon” + ctr;
    document.getElementById(subMenuCellA).src = ‘images/iconLeftnavEmpty.png’; //reset menu icon to empty
    }
    alert(‘submenu1’);
    }

  • The topic ‘Javascript menus not working in Firefox’ is closed to new replies.