Firefox offsetLeft

P

Paul Nash

This is a dropdown menu script thats works ok in IE but is not positioning
properly in Firefox. m.style.pixelLeft and Top are being set to the right
values. But the menu, in a div block, is being displayed as though the
pixelLeft and Top are being ignored.

<script type='text/javascript' >
var cm=null;
document.onclick = new Function("show(null)")
function getPos(el,sProp) {
var iPos = 0
while (el!=null) {
iPos+=el["offset" + sProp]
el = el.offsetParent
}
return iPos
}

function show(el,m) {
if (m) {
m.style.pixelLeft = getPos(el,"Left")
m.style.pixelTop = getPos(el,"Top") + el.offsetHeight
m.style.display='';
}
if ((m!=cm) && (cm)) cm.style.display='none'
cm=m
}
</script>
.. . .
<a href='page?page=gifts' class='menulink'
onmouseover='show(this,menu_gifts);' >
Gifts
</a>
.. . .

<!-- MENU BOX for gifts -->
<div id='menu_gifts' class='submenu' style='display: none;' >

<!-- start of imagebox -->
<table cellspacing='0' cellpadding='0' border='0'>
<tbody>
.. . .

Regards, Paul Nash
 
R

Robert

Paul said:
This is a dropdown menu script thats works ok in IE but is not positioning
properly in Firefox. m.style.pixelLeft and Top are being set to the right
values.

pixelLeft and pixelTop are IE specific properties. Of course you can add
these properties, but they don't have any meaning for Firefox.
function show(el,m) {
if (m) {
m.style.pixelLeft = getPos(el,"Left")
m.style.pixelTop = getPos(el,"Top") + el.offsetHeight

Try this:
m.style.left = getPos(el,"Left") + "px";
m.style.top = (getPos(el,"Top") + el.offsetHeight) + "px";

Robert.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top