473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Crossbrowser element dimensions

Hi,

I'd like to know where I can find some informations on how to retrive
element dimensions in a cross browser whay. Until now I used
offsetWidth and offsetHeight, but I know their are not standard and
they have a different behaviour on different browsers. I need a way
that includes also margins, padding and eventually border size. I know
I have to deal with doctypes, but my javascript knowledge is not so
advanced.

There is any ready to use library or anyone interested in helping me ?

Gabriele

Jul 12 '06 #1
3 2763
Gabriele Farina wrote:
Hi,

I'd like to know where I can find some informations on how to retrive
element dimensions in a cross browser whay. Until now I used
offsetWidth and offsetHeight, but I know their are not standard and
they have a different behaviour on different browsers. I need a way
that includes also margins, padding and eventually border size. I know
I have to deal with doctypes, but my javascript knowledge is not so
advanced.

There is any ready to use library or anyone interested in helping me ?
Poke around <URL:http://www.quirksmode.org/>
--
Rob
Jul 12 '06 #2
Gabriele Farina wrote:
I'd like to know where I can find some informations on how to retrive
element dimensions in a cross browser whay. Until now I used
offsetWidth and offsetHeight, but I know their are not standard and
they have a different behaviour on different browsers. I need a way
that includes also margins, padding and eventually border size.
offsetWidth and offsetHeight are not standard properties, but they are well
supported in many browsers and include padding and padding, but not margin
(why would you want to include the margin?).

Otherwise there is no reliable way to get the size of an element, because
CSS can be used with units other than pixels. For example:
DIV {
border-left:10em;
border-right:10%;
padding:2in;
}
Trying to find the outer dimensions of that DIV by inspecting CSS values is
going to get you nowhere.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 12 '06 #3
Ok, thanks.

I think I'll use only offsetWidth and offsetHeight. The behave well on
quite all the browsers my application have to support.

Gabriele

Jul 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: delerious | last post by:
I need to determine an element's width and height in pixels (not including padding, border, and margin) in Javascript. The element will not have width or height styles specified. In Mozilla, I...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
2
by: Christopher Benson-Manica | last post by:
I want to load content into an iframe with script. None of the following methods, however, work on all browsers - any suggestions would be appreciated. // Assume that there is an element whose...
2
by: awoodgate | last post by:
Hi, I'm trying to read the width of a css absolutely positioned element in javascript. If I use an id selector or a class definition then the width is null, but if I use an inline style then it...
3
by: Steel | last post by:
Hi at all, I'ld want to know if position:absolute is crossbrowser. Infact I cannot position absolutely an element in the some place with fox-pro and MSIE6 There is always a little difference...
0
by: Pablito | last post by:
Hi at all, I have a little problem about position:absolute. I want to position absolutely a menu bar. if I write: menubar {position: absolute;top:5.2em;} with MSIE the menu bar is too height on...
3
by: toffee | last post by:
Hi all, Here's the situation: I have a table of data; and I would like to add a div with exactly the same height and width as the top-left header. The problem is as the data is dynamic and the...
53
by: brave1979 | last post by:
Please check out my javascript library that allows you to create any layout for your web page, nested as deep as you like, adjusting to width and height of a browser window. You just describe it in...
1
by: par7133 | last post by:
Hi, Yea, XMLHttpRequest give out a crossbrowser problem managing the status change of the connection. Here the solution: var xmlhttp; xmlhttp=null;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.