View Single Post
  #2 (permalink)  
Old September 7th, 2003, 05:29 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Jeri,

I am not 100% sure, but I don't think you can do that. Consider the following example:
Code:
<html>
<head>
  <title>Test Width</title>
  <script language="JavaScript" type="text/javascript">
  function TestMe()
  {
    alert(document.getElementById('spTest').style.width);
  }
  </script>
</head>
<body>
  <span id="spTest">This is a test</span>
  <input type="button" value="Click" onclick="TestMe();">
</body>
</html>
If you run this, and click the button, you'll get an empty dialog box, indicating that the width is empty / null / undetermined.

If you change the span tag to this:
Code:
  <span id="spTest" style="width: 100px">
the dialog box will now show "100px". So I am afraid that it looks like the browser won't tell you how wide an element is if you haven't explicitly stated it first.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.