By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,814 Members | 2,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,814 IT Pros & Developers. It's quick & easy.

IE problem with offsetWidth

P: n/a
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.

Sep 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

Sep 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.