dcsimg
Menu Code Problem in IE5! Can you help?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Peter_Muir
Posted On:   Tuesday, July 1, 2003 06:06 AM

Hello all, I'm having problems with some code that makes a expandable/collapsible tree menu from an unordered list. The script works fine in IE6 but in IE5 the menu doesn't display at all and returns the following error: Line: 98 Char: 35 Error: Object doesn't support this property or method I'm really hoping there is a workaround or fix to this as although I know there are a lot of menu scripts out there this one is perfect for me. Thank you in advance, Peter CODE.... var menuItems = new Array() function drawList(list,parent,level) { if(!level) level = 1; for(var i=0;i var newDiv = document.createElement("div&qu   More>>

Hello all,



I'm having problems with some code that makes a expandable/collapsible tree menu from an unordered list. The script works fine in IE6 but in IE5 the menu doesn't display at all and returns the following error:


Line: 98
Char: 35
Error: Object doesn't support this property or method



I'm really hoping there is a workaround or fix to this as although I know there are a lot of menu scripts out there this one is perfect for me.



Thank you in advance,



Peter



CODE....



var menuItems = new Array()

function drawList(list,parent,level) {

if(!level) level = 1;


for(var i=0;i

var newDiv = document.createElement("div");

newDiv.className = "menuItem menuLevel" + level + " menutext";

newDiv.appendChild(document.createTextNode(list.items[i].caption));

newDiv.href = list.items[i].href;

newDiv.level = level;


if(i==0 && level==1) newDiv.style.border = "";


Toolkit.Events.addListener(newDiv,"onmouseover",menuOver,newDiv);

Toolkit.Events.addListener(newDiv,"onmouseout",menuOut,newDiv);

Toolkit.Events.addListener(newDiv,"onclick",menuClick,newDiv);


if(list.items[i].subList!=null) {

var plus = document.createElement("div");

plus.level = level;


plus.className = "menuExpand menuExpandLevel" + level + " menutext";

plus.appendChild(document.createTextNode("+"));


Toolkit.Events.addListener(plus,"onmouseover",expanderOver,plus);

Toolkit.Events.addListener(plus,"onmouseout",expanderOut,plus);

Toolkit.Events.addListener(plus,"onclick",expanderClick,plus);


var children = document.createElement("div");

drawList(list.items[i].subList,children,level+1);

plus.target = children;


newDiv.appendChild(plus);

newDiv.appendChild(children);

}


if(list.items[i].className!="selected") {

newDiv.selected = false;

if(list.items[i].subList!=null) children.style.display = "none";

} else {

newDiv.selected = true;

newDiv.className = "menuItem menuSelected menuLevel" + level + " menutext";

}


menuItems.push({obj: newDiv, href: list.items[i].href});


parent.appendChild(newDiv);


}


return newDiv;

}


function init() {

var daList = document.getElementById("menu").getElementsByTagName("ul")[0];

daList.style.display = "none";


var list = new ListObject(daList);

var cont = document.getElementById("menu");

lastChild = drawList(list,cont);

//lastChild.style.borderBottom = "1px solid #272D2F";


document.getElementById("menu").style.height = (document.getElementById("content").offsetHeight-document.getElementById("menu").offsetTop)
+ "px";

document.getElementById("content").style.height = document.getElementById("contents").offsetHeight
+ "px";


document.getElementById("pageTitle").onclick = function() { location
= "/"; }

document.getElementById("pageTitle").onmouseover = function() { window.status
= "http://pupius.co.uk/"; }

document.getElementById("pageTitle").onmouseout = function() { window.status
= ""; }

}




function menuOver(e) {


this.className = "menuItem menuLevel" + this.level + "Over
menutext";

window.status = this.href;

Toolkit.Events.cancelEvents(e);

}


function menuOut(e) {

if(this.selected) this.className = "menuItem menuSelected menuLevel" +
this.level + " menutext";

else this.className = "menuItem menuLevel" + this.level + " menutext";

window.status = "";

e.stopPropagation();

}


function menuClick(e) {

location = this.href;

//alert(this.level);

e.stopPropagation();

}


function expanderOver(e) {

this.className = "menuExpand menuExpandLevel" + this.level + "Over
menutext";

e.stopPropagation();

}


function expanderOut(e) {

this.className = "menuExpand menuExpandLevel" + this.level + " menutext";

e.stopPropagation();

}


function expanderClick(e) {

if(this.target.style.display == "none") this.target.style.display
= "block";

else this.target.style.display = "none";


e.stopPropagation();

}

   <<Less

Re: Menu Code Problem in IE5! Can you help?

Posted By:   Nitesh_Naveen  
Posted On:   Tuesday, July 1, 2003 10:18 AM

The error code seems to be picked up from IE status bar, which gives the line number relative to the equivalent page generated. So your code given here doesn't really help. Try installing the MS script debugger and track the error. Seems like the problem is it is basically not able to get an object.



If your menu is IE only, why not try using document.all['element_name'] instead of document.getElementById('element_name')
About | Sitemap | Contact