justin001
10-10-2003, 05:19 AM
Please help!
The following functions build DIVs and handle their events respectively. As you will see, the DIV builder has the mouseover et al references coded into it. It passes an ID, that has been assigned to the DIV or inner DIV element to the menuEventHandler function, which then uses document.all[passed id] to get the event out of the body. But it doesn't work. When I look at the object that it calls, it has two properties – both with the name of ID, and both are objects. Why is it not calling the HTML element with the id that is passed? Thanks in advance.
I ONLY NEED IE6+ COMPLIANCE, AND I HAVE CODED FOR THIS BROWSER SPECIFICALLY
Script Scrap:
function createMenus(pArray,pParent)
{
var content="";
var tempChild;
var menuID="menu"+menuElAr["menus"].length;
var triggerID="";
content+="<div class='menuContainer' id='"+menuID+"' "+
"onmouseover=\"menuEventHandler('"+menuID+"','over')\" onmouseout=\"menuEventHandler('"+menuID+"','out')\""+
"><table border='1' cellspacing='0' cellpadding='0'>";
menuElAr["menus"][menuElAr["menus"].length]=new MenuRefObj(menuID,pParent||"");
for (var i=0;i<pArray.length;i++)
{
triggerID="trigger"+menuElAr["triggers"].length;
if (pArray[i].child) tempChild=createMenus(pArray[i].child,triggerID);
content+="<tr><td class='menuTrigger' id='"+triggerID+"' "+
"onmouseover=\"menuEventHandler('"+triggerID+"','over')\" onmouseout=\"menuEventHandler('"+triggerID+"','out')\">"
if (pArray[i].ref) content+="<a href='"+pArray[i].ref+"'>";
content+=pArray[i].name;
if (pArray[i].ref) content+="</a>";
content+="</td></tr>";
menuElAr["triggers"][menuElAr["triggers"].length]=new TriggerRefObj(triggerID,pArray[i].ref||"",tempChild||"");
tempChild="";
}
content+="</table></div>\n";
HTMLMenuContent[HTMLMenuContent.length]=content;
return (menuID)
}
function menuEventHandler(pID,pAct)
{
var content="";
for (var i in document.all[pID])
content+=i+" "+document.all[pID][i][0]+"\n";
alert(content);
switch (pAct)
{
case "over":
if (findMenuEl(document.all[pID],"triggers"))
var obj=findMenuEl(document.all[pID],"triggers");
if (obj.mChild);
showHide(document.all[obj.mChild.mID],1);
break;
case "out":
break;
}
}
The following functions build DIVs and handle their events respectively. As you will see, the DIV builder has the mouseover et al references coded into it. It passes an ID, that has been assigned to the DIV or inner DIV element to the menuEventHandler function, which then uses document.all[passed id] to get the event out of the body. But it doesn't work. When I look at the object that it calls, it has two properties – both with the name of ID, and both are objects. Why is it not calling the HTML element with the id that is passed? Thanks in advance.
I ONLY NEED IE6+ COMPLIANCE, AND I HAVE CODED FOR THIS BROWSER SPECIFICALLY
Script Scrap:
function createMenus(pArray,pParent)
{
var content="";
var tempChild;
var menuID="menu"+menuElAr["menus"].length;
var triggerID="";
content+="<div class='menuContainer' id='"+menuID+"' "+
"onmouseover=\"menuEventHandler('"+menuID+"','over')\" onmouseout=\"menuEventHandler('"+menuID+"','out')\""+
"><table border='1' cellspacing='0' cellpadding='0'>";
menuElAr["menus"][menuElAr["menus"].length]=new MenuRefObj(menuID,pParent||"");
for (var i=0;i<pArray.length;i++)
{
triggerID="trigger"+menuElAr["triggers"].length;
if (pArray[i].child) tempChild=createMenus(pArray[i].child,triggerID);
content+="<tr><td class='menuTrigger' id='"+triggerID+"' "+
"onmouseover=\"menuEventHandler('"+triggerID+"','over')\" onmouseout=\"menuEventHandler('"+triggerID+"','out')\">"
if (pArray[i].ref) content+="<a href='"+pArray[i].ref+"'>";
content+=pArray[i].name;
if (pArray[i].ref) content+="</a>";
content+="</td></tr>";
menuElAr["triggers"][menuElAr["triggers"].length]=new TriggerRefObj(triggerID,pArray[i].ref||"",tempChild||"");
tempChild="";
}
content+="</table></div>\n";
HTMLMenuContent[HTMLMenuContent.length]=content;
return (menuID)
}
function menuEventHandler(pID,pAct)
{
var content="";
for (var i in document.all[pID])
content+=i+" "+document.all[pID][i][0]+"\n";
alert(content);
switch (pAct)
{
case "over":
if (findMenuEl(document.all[pID],"triggers"))
var obj=findMenuEl(document.all[pID],"triggers");
if (obj.mChild);
showHide(document.all[obj.mChild.mID],1);
break;
case "out":
break;
}
}