IE problem with offsetWidth

B

Beni Rose

I'm trying to build some dynamic vertical drop down menus (pop out
menus?) and I'm having some trouble. I'm trying to get the width of the
span tag that the root level menu item is in, because it's going to be
different every time (it's a solution for a template driven website
solution). I'm not assigning the width in my javascript for the same
reason. So when I do span.width or span.style.width I get undefined.
However, in Safari and Firefox, I can use offsetWidth to get the
alloted width of my span tag. In IE, however, my offsetWidth is 0, as
well as any other width alternative I could find.

So my question is, if I don't set the width of an object, how can I
retrieve the width alloted to it by the browser. Again, it's a span
tag. I could use div if it makes a difference, but IE doesn't fire
onmouseover when you mouse over empty space in a div tag, so that's why
I went with a span.
 
B

Beni Rose

If it helps, I realized that it's because for some unG-dly reason, IE
is processing all this javascript before the page loads, so when it
gets to my span.offsetWidth, the current offsetWidth really is 0,
because the object hasn't been displayed yet. So my new question is,
how do I wait until after the object is finished loading to change it
around. I tried span.onload = function(){ div.left = span.offsetWidth;}
but that doesn't work. But at least now it's displaying the proper
offsetWidth when I send it to an alert in the onmouseover of the span.
 

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,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top