...

View Full Version : Wrong offsetWidth value on IE



BarrMan
07-27-2009, 11:10 PM
Hey,
I'm trying to make my dropdown work on IE but it keeps getting wrong values for the offsetWidth.
Also, I'm trying this on IE 6.

Here's the page:
http://ofracalifa.com/he/?id=1

Here's the JS function:

function DropDown(opts, obj, rtl) {
var ie = (document.all) ? true : false;
var objTop = obj.offsetHeight + findPos(obj)[1];
var objLeft = findPos(obj)[0];
var optsHeight, optsWidth;
var e;
/* $('Rawr').innerHTML += "objTop: "+objTop+" - contTop: "+contTop+", objLeft: "+objLeft+" - contLeft: "+contLeft+"<br />";*/
if(contLeft!=objLeft||contTop!=objTop)
{
contLeft = objLeft;
contTop = objTop;
if (ie) {
optsWidth = opts.offsetWidth;
opts.style.position = "absolute";
}
else {
opts.style.position = "absolute";
optsWidth = opts.offsetWidth;
}
optsHeight = opts.offsetHeight;
var CalculateLeft = objLeft - ((!!rtl) ? (optsWidth - obj.offsetWidth) : 0);
if(!rtl)
CalculateLeft += 24;
CalculateLeft = toEms(CalculateLeft);
opts.style.left = CalculateLeft + "em";
var bodyHeight = document.documentElement?document.documentElement.clientHeight:bodyHeight.offsetHeight;
if(obj.offsetHeight + optsHeight+objTop>bodyHeight)
opts.style.top = toEms(objTop-optsHeight-obj.offsetHeight)+"em";
else
opts.style.top = toEms(objTop) + "em";

try {
opts.style.cursor = "pointer";}
catch(e) {
opts.style.cursor = "hand";}
}
}

And here is the sub nav:

<div id="SubNavContainer">
<div id="SubNav">
<a href="?id=1&sid=4">משי</a>
<a href="?id=1&sid=5">קטיפה</a>
<a href="?id=1&sid=6">הדפסים</a>
<a style="background:0;" href="?id=1&sid=7">אריגה</a>

</div>
<img src="../images/navarrow.gif" />
</div>

And the CSS:

#SubNav
{
background-color:#750707;
height:1.5em;
padding:0;
margin:0;
}
#SubNav a
{
padding:0;
margin:0;
margin-left:1em;
margin-right:0.5em;
padding-left:1.5em;
background-image:url(images/bullet.jpg);
background-repeat:no-repeat;
background-position:0em 0.6em;
color:White;
}
#SubNavContainer
{
position:absolute;
}

Can anyone direct me to where the problem might be because I've tried alerting the offsetWidth and the calculated left values and they came out different from what the values in firefox.

Thanks for any help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum