Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get the width of an auto ID

Status
Not open for further replies.

fredes65

Programmer
Mar 2, 2002
9
AU
I have a DIV style thats width is set to auto.

Can I get the width of the div through javascript?

Ive tried everything I know

cheers
fred
 
I beleive DOM 1 or 2 supports a method called getComputedStyle that will grab the value of a css property. I know Netscape 6.x supports almost all of this feature...don't know about IE tho.

check out the DOM spec on the w3's site...

===
Supports Mozilla and Web Standards
Knows HTML/XHTML, CSS1, JavaScript, PHP, C++, DOM1
===
 
Just use
Code:
document.getElementById('myDiv').offsetWidth;
In Netscape 4, use
Code:
document.layers['myDiv'].clip.width;
bluebrain.gif
blueuniment.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top