[[Javascript]] width and height of an element

Lee Hinde leehinde at gmail.com
Sun Sep 24 13:41:40 CDT 2006


I'm glad you found what you are after, but, since I'm touchy, I wanted
to show you how I tested before I sent that link:


<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>untitled</title>
	<meta name="generator" content="TextMate http://macromates.com/">
	<meta name="author" content="Lee Hinde">
	<!-- Date: 2006-09-24 -->
	<script type="text/javascript" charset="utf-8">
	function howbig(){
			myitem=document.getElementById("item");
			alert(myitem.offsetHeight);
			
		}
	</script>
</head>
<body>
<div id="item" onclick="howbig()">
		Here I am.
	</div>
</body>
</html>


That gives me an answer....



On 9/24/06, Bernu Bernard <bernu at lptmc.jussieu.fr> wrote:
> Thanks for your response but it does not answer my needs.
>
> The site you mentioned give a size of an element which has that size
> (width or height) already set.
>
> My question is what you do when the browser decides the width and
> size of the element.
> The usual need is when you precise the width and you want to find
> what the browser has set for the height.
>
> When you directly ask the height you get nothing (null or undefined).
>
> Bernard
> Le Sep 24, 2006 à 6:33 PM, Lee Hinde a écrit :
>
> > On 9/24/06, Bernu Bernard <bernu at lptmc.jussieu.fr> wrote:
> >> Hi list,
> >>
> >> How can I find the width and size of an element ?
> >>
> >> Say for example I have :
> >>
> >> <div id="test" onclick="getsizes()">hello</div>
> >>
> >> When I click on "hello" I'd like to get the width and height of this
> >> element.
> >>
> >> Bernard
> >> _______________________________________________
> >
> >
> > Google is your friend. I found this:
> >
> > http://www.aspandjavascript.co.uk/javascript/javascript_api/
> > get_element_width_height.asp
> >
> > (o, google est vous ami? :-) )
> > --
> > Mark Twain: "What gets us into trouble is not what we don't know. It's
> > what we know for sure that just ain't so."
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>


-- 
Mark Twain: "What gets us into trouble is not what we don't know. It's
what we know for sure that just ain't so."



More information about the Javascript mailing list