Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-01-2003, 02:22 PM   PM User | #1
pedro
New to the CF scene

 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
pedro is an unknown quantity at this point
Menu problem and IE5...

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:

Quote:
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<list.items.length;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();
}


//error point's to next line
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();
}

Last edited by pedro; 07-01-2003 at 03:34 PM..
pedro is offline   Reply With Quote
Old 07-01-2003, 03:31 PM   PM User | #2
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
But which line in the code you posted is the one that the error is pointing to?
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 07-01-2003, 03:35 PM   PM User | #3
pedro
New to the CF scene

 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
pedro is an unknown quantity at this point
Sorry, just edited the post to make it more clear...

It's the line that starts,

function expanderOut(e) {

but I really can't see what's wrong here at all?!
pedro is offline   Reply With Quote
Old 07-01-2003, 04:25 PM   PM User | #4
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
I think it's a handler problem, try changing this line:

e.stopPropagation();

to

if (e.stopPropagation) e.stopPropagation();
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 07-01-2003, 04:52 PM   PM User | #5
pedro
New to the CF scene

 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
pedro is an unknown quantity at this point
Hmmm... sorry this didn't work, I replaced all instances of this line but to no avail. Thank you for trying.
pedro is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:02 PM.


Advertisement
Log in to turn off these ads.