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


justin001
10-17-2003, 02:44 AM
I have revised the code and it works partially in Opera, fully in IE. What might be wrong? Thanks in advance..

var menuRef=new Array();
var menuNames=["prod"];
function findCurrMenu(pObj)
{
for (var i=pObj;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 firstPop(pMenu,pSrc)
{
if (menuRef.length)
{
hideAll();
menuRef.length=0;
}
else
{
addToRef(pMenu,pSrc.name);
refreshMenus();
if (pMenu)
{
document.getElementById(pMenu).style.top=getFullPos(pSrc,"y")+pSrc.offsetHeight+2;
document.getElementById(pMenu).style.left=getFullPos(pSrc,"x");
}
}
}

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

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

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

function addToRef(pId,pPos)
{
menuRef[pPos]=pId;
menuRef.length=eval(pPos)+1;
}

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

function eHandler(pAction,pSrcEvent,pPopInfo)
{
var useObj=document.getElementById(pSrcEvent);
switch(pAction)
{
case "over":
document.getElementById(pSrcEvent).className="mTransOver";
findCurrPointer(useObj)["className"]="menuCellOver";
pop(pPopInfo,findCurrPointer(useObj));
break;
case "out":
document.getElementById(pSrcEvent).className="mTransOut";
findCurrPointer(useObj)["className"]="menuCellOut";
break;
}
}

function changeURL(pURL)
{
document.location=pURL;hideAll();
}

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;
}

justin001
10-17-2003, 09:36 AM
Anyone? Please help?

xag
10-17-2003, 09:40 AM
try reading the message posting guidelines.

How are we supposed to know what your code is meant to do?

justin001
10-20-2003, 01:18 AM
Fair enough. Sorry the code is my attempt at popup menus. There are various functions in the code that basically position the DIVs (not included) according to the top, height positions of the source elements. But that's really not what I'm asking for help with. I'm asking about the actual DHTML statements. Like is (EG) document.whatever a valid thing in the Opera/netscape DOM. I'm really not worried too much about the code logic, just the various pieces. And are there any quircks you've noticed with non-IE browsers and mouseovers etc.. when dealing w DIVs?

Thanks again,
Justin

And when I get some time, I'll have a look at those guidelines you were talking about :)