Click to See Complete Forum and Search --> : Cross Browser


justin001
10-14-2003, 10:22 AM
I KNOW this works in IE6. Does anyone have any pointers on how I can make it work in Opera and Netscape? Code below, style sheets and all else in zip file.

<script language="JavaScript">
<!--
var menuRef=new Array();
var menuNames=["prod"];
function findCurrMenu(pObj)
{
for (var i=event.srcElement;i.tagName!="BODY";i=i.parentElement)
if (i.tagName=="DIV")
return i.name;
}

function findCurrPointer(pCurrElement)
{
for (var i=pCurrElement;i.tagName!="BODY";i=i.parentElement)
if (i.className=="menuCellOut"||i.className=="menuCellOver")
return i;
return false;
}

function pop(pMenu,pSrc)
{
if (!pMenu);
else
{
addToRef(document.getElementById(pMenu).name,pMenu);
refreshMenus();
document.getElementById(pMenu).style.top=getFullPos(pSrc,"y");
document.getElementById(pMenu).style.left=getFullPos(pSrc,"x")+document.getElementById(pMenu).offsetWidth;
}
}

function hideAll()
{
for (var i=0;i<menuNames.length;i++)
for (var j=1;document.getElementById(menuNames[i]+"$"+j);j++)
document.getElementById(menuNames[i]+"$"+j).style.display="none";
}

function refreshMenus()
{
hideAll();
for (var i=0;i<menuRef.length;i++)
if (menuRef[i])
document.getElementById(menuRef[i]).style.display="block";
}

function addToRef(pName,pId)
{
menuRef[pName.split("$")[2]]=pId;
menuRef.length=pName.split("$")[2]+1;
}

function unPop(pMenu)
{
document.getElementById(pMenu).className="menuHidden";
}

function eHandler(pAction)
{
var useObj=event.srcElement;
switch(pAction)
{
case "over":
findCurrPointer(useObj)["className"]="menuCellOver";
pop(findCurrPointer(useObj).name,findCurrPointer(useObj));
break;
case "out":
findCurrPointer(useObj)["className"]="menuCellOut";
break;
}
}

function getFullPos(pObj,pAxis)
{
var measurement=0;
var prop=(pAxis=='y')?'offsetTop':'offsetLeft';
for (var i=pObj;i.tagName!="BODY";i=i.offsetParent)
measurement+=i[prop];
return measurement;
}
//-->
</script>

gil davis
10-14-2003, 01:39 PM
The first block I see has to do with the "event" object. That is a Micro$oft proprietary object. Neither Netscape nor Opera have such an object. You will have to look into the event model for those browsers an find the appropriate object to use in your routine.

For Netscape, you can find information on their DevEdge web site http://devedge.netscape.com/central/javascript/

justin001
10-14-2003, 11:10 PM
Thanks for the help! I will look into it immediately..

Cheers,
Justin