HighDots Forums  

IE problem with offsetWidth

Javascript JavaScript language (comp.lang.javascript)


Discuss IE problem with offsetWidth in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Beni Rose
 
Posts: n/a

Default IE problem with offsetWidth - 09-06-2006 , 06:44 PM






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.


Reply With Quote
  #2  
Old   
Beni Rose
 
Posts: n/a

Default Re: IE problem with offsetWidth - 09-06-2006 , 07:02 PM






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.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.