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

standard way to get the width of an element

P: n/a
Hello,
I am looking for a cross browser way (IE, Firefox, Safari) of
getting the screen width, in pixels, of an element on my page. I am
interested in the "navImg" table cell. Here is a snippet of code:

<tr>

<td style="width:45px; height:38px;" id="navImg" name="navImg"><img
src="images/NAV_07.gif" alt="" border="0"></td>

How would I use JS to get this width? (I can't just use 45 as a
hard-coded value, because I may be going in and changing this table
cell).

Thanks, - Dave

Oct 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

la***********@zipmail.com wrote:
I am looking for a cross browser way (IE, Firefox, Safari) of
getting the screen width, in pixels, of an element on my page.


element.offsetWidth

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 18 '05 #2

P: n/a
la***********@zipmail.com wrote:
Hello,
I am looking for a cross browser way (IE, Firefox, Safari) of
getting the screen width, in pixels, of an element on my page. I am
interested in the "navImg" table cell. Here is a snippet of code:

<tr>

<td style="width:45px; height:38px;" id="navImg" name="navImg"><img
src="images/NAV_07.gif" alt="" border="0"></td>

How would I use JS to get this width? (I can't just use 45 as a
hard-coded value, because I may be going in and changing this table
cell).

Thanks, - Dave


In regard to cross-browser-nes, usefull stuff is located here:

<URL:http://www.quirksmode.org/viewport/compatibility.html>
--
Rob
Oct 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.