SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Screamager45's Avatar
    Join Date
    Dec 2003
    Location
    Norwich
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    navigation menus...

    Hello,

    I'm trying to create a navigation menu for a website I am working on. The idea is that navigation branches collapse and expand to show further child navigation options.

    Basically it needs to work in the same way as on the Left hand side of this page...

    http://hotwired.lycos.com/webmonkey/backend/databases/

    I am having a bit of difficulty. I have managed to work out what I think the javascript in this page is doing, but I can't seem to get it to work on my site.

    I am using the following code...

    document.WM = new Object();
    document.WM.menu = new Object();
    document.WM.menu.dropdown = new Array();

    function WM_initializeToolbar()
    {
    var i;
    if (document.all)
    {
    for(i = 0; i < document.all('container').all.length; i++)
    {
    if ((document.all('container').all[i].className == 'header') || (document.all('container').all[i].className == 'links'))
    {
    document.WM.menu.dropdown[document.WM.menu.dropdown.length] = document.all('container').all[i];
    }
    }
    } else if (document.getElementsByTagName && document.getElementById)
    {
    var contained = document.getElementById('container').getElementsByTagName('div');
    for(i = 0; i < contained.length; i++)
    {
    if ((contained[i].getAttribute('class') == 'header') ||(contained[i].getAttribute('class') == 'links'))
    {
    document.WM.menu.dropdown[document.WM.menu.dropdown.length] = contained[i];
    }
    }
    }
    }

    function WM_collapse(item)
    {
    if(document.WM.menu.dropdown.length)
    {
    if (document.WM.menu.dropdown[item + 1].style.display == 'none')
    {
    document.WM.menu.dropdown[item + 1].style.display = '';
    if(document.WM.menu.dropdown[item].id == 'webmonkey')
    {
    document.images[document.WM.menu.dropdown[item].id +'Img'].src = '/webmonkey/images/open_gray.gif';
    }
    else
    {
    document.images[document.WM.menu.dropdown[item].id +'Img'].src = '/webmonkey/images/open.gif';
    }
    }
    else
    {
    document.WM.menu.dropdown[item + 1].style.display = 'none';
    if(document.WM.menu.dropdown[item].id == 'webmonkey')
    {
    document.images[document.WM.menu.dropdown[item].id +'Img'].src = '/webmonkey/images/closed_gray.gif';
    }
    else
    {
    document.images[document.WM.menu.dropdown[item].id +'Img'].src = '/webmonkey/images/closed.gif';
    }
    }
    }
    }


    I get the error
    "'document.WM.menu.dropdown[...].style' is null or not an object.

    I am assuming that this means that the ids of the divs in the container are not being loaded properly in to the array, but I do not know how to solve this.

    Any help would be appreciated.
    (I'm afraid that the site I am working on is not live, so I can't show you a working version)

    Thanks

    Dave

  2. #2
    SitePoint Enthusiast Screamager45's Avatar
    Join Date
    Dec 2003
    Location
    Norwich
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok,
    So in the last hour I've managed to work out that the arrray is empty.
    Still flumoxed though, so any help would be grand




    Thanks

    Dave


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
  •