Forum Moderators: open

Message Too Old, No Replies

netscape not expanding menu

expanding menu

         

mesathinks

12:58 am on Dec 21, 2007 (gmt 0)

10+ Year Member



I would appreciate any input:

I use the following code to expand a submenu block in a <dl> menu.

function checksubmnu(id) {

var d = document.getElementById(id);

for (var i = 1; i<=10; i++) {
if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}

}

//if it exist show it
if (d) {d.style.display='block'};

}

In IE6 and netscape it works pefectly when I define the UL/LI but when I use createElement to create the choices the block shows but will not move down the rest of the menu, rather it is in the background in netscape 9. In IE is still works perfectly.

The sub is created with :

var dt = document.createElement('dt');
dt.appendChild(document.createTextNode('Menu '+mname));


var dd = document.createElement('dd');
dd.setAttribute('id','smenu'+mname);
var ul = document.createElement('ul');

var li1 = document.createElement('li');
var a = document.createElement('a');
a.setAttribute('href', '#');
a.appendChild(document.createTextNode('sub menu 3.1'));
a.onclick = function () {test()};
li1.appendChild(a);
ul.appendChild(li1);

var li2 = document.createElement('li');
var a = document.createElement('a');
a.setAttribute('href', '#');
a.appendChild(document.createTextNode('sub menu 3.2'));
a.onclick = function () {test()};
li2.appendChild(a);
ul.appendChild(li2);

dd.appendChild(ul);
dt.appendChild(dd);
dt.onclick = function () {checksubmnu(dd.id)};
document.getElementById('mmenu').appendChild(dt);

JAB Creations

1:46 am on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you appending a unique ID to the element, and then are you calling the correct ID? I don't have anything more critical then that as I'm still learning JavaScript. :)

- John

mesathinks

5:22 pm on Dec 27, 2007 (gmt 0)

10+ Year Member



Thanks for the input. I finally furgured it out and it still stumps me. I took out the height statements in the css portion and it now works in IE/NS and FF perfectly. Still fail to see the connection as height works in all three in other respects.