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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape Object.Width Returns "Undefined"?

Status
Not open for further replies.

JTeagle

Programmer
May 30, 2000
49
GB
In IE I can get the current width of a DIV object defined by a stylesheet by saying document.all[&quot;DIVName&quot;].style.width. If I try to get the width in Netscape using document.layers[&quot;DIVName&quot;].width, it returns &quot;Undefined&quot; (left and top are OK, width and height are not) - anyone know what I'm doing wrong? <br><br>Here's a sample HTML page source demonstrating the problem (Netscape only):<br><br>&lt;HTML&gt;&lt;BR&gt;<br>&lt;HEAD&gt;&lt;TITLE&gt;Nutscape Test&lt;/TITLE&gt;&lt;BR&gt;<br>&lt;STYLE TYPE=&quot;text/css&quot;&gt;&lt;BR&gt;<br>&nbsp;&nbsp;#CategorySelectDIV {position: absolute ; left: 10px ; top: 10px ; &lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 400px ; height: 90px ; visibility: &quot;show&quot;; }&lt;BR&gt;<br>&lt;/STYLE&gt;&lt;BR&gt;<br>&lt;/HEAD&gt;&lt;BR&gt;<br>&lt;BODY&gt;&lt;BR&gt;<br>&lt;DIV ID=&quot;CategorySelectDIV&quot;&gt;&lt;BR&gt;<br>This is some text in the DIV.&lt;BR&gt;<br>&lt;/DIV&gt;&lt;BR&gt;<br>&lt;BR&gt;<br>&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;&lt;BR&gt;<br>document.writeln(&quot;&lt;BR&gt;&lt;BR&gt;&quot;);&lt;BR&gt;<br>document.writeln(&quot;Left = &quot; + document.layers[&quot;CategorySelectDIV&quot;].left + &quot;&lt;BR&gt;&quot;);&lt;BR&gt;<br>document.writeln(&quot;Width = &quot; + document.layers[&quot;CategorySelectDIV&quot;].width + &quot;&lt;BR&gt;&quot;);&lt;BR&gt;<br>&lt;/SCRIPT&gt;&lt;BR&gt;<br>&lt;/BODY&gt;&lt;BR&gt;<br>&lt;/HTML&gt;&lt;BR&gt;<br><br>Just below the phrase in the DIV block it prints &quot;Left = 10&quot; and &quot;Width = undefined&quot;.<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top