770 snippets from 1550 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
PHP
(136)
JavaScript
(123)
Java
(66)
VBSCRIPT
(58)
String
(44)
CSS
(31)
CSharp
(28)
File
(28)
HTML
(27)
C
(24)
mysql
(24)
VB.NET
(24)
python
(24)
CPlusPlus
(23)
groovy
(23)
New Snippets
Very lightweight ...
AutoComplete plug...
AutoComplete plug...
Connection Java -...
View PostgreSql
Store Procedure
Pygame - Simple p...
Python - Anagram ...
Python - Anagram ...
Converter to bina...
Venture Capital Jobs
New Members
me
jamesmcm
Can
Kelmi
ysg
dannymo2
chorny
wallie
Hackdemian
impomatic
Top Members
dannyboy
sundaramkumar
mattrmiller
Pio
i_kenneth
ASmith
ctiggerf
sehrgut
bertheymans
SCoon
Home
/
Snippets
/
Get computed Height of an HTML Element
/
Comments
Get computed Height of an HTML Element
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
New Comment
The missing bit:
Mon. Oct. 22nd, 2007 9:04 AM
richard123
To make it complete...
function
getComputedHeight
(
theElt
)
{
var
browserName=navigator.
appName
;
if
(
browserName==
"Microsoft Internet Explorer"
)
{
var
is_ie=
true
;
}
else
{
var
is_ie=
false
;
}
if
(
is_ie
)
{
tmphght = document.
getElementById
(
theElt
)
.
offsetHeight
;
}
else
{
docObj = document.
getElementById
(
theElt
)
;
var
tmphght1 = document.
defaultView
.
getComputedStyle
(
docObj,
""
)
.
getPropertyValue
(
"height"
)
;
tmphght = tmphght1.
split
(
'px'
)
;
tmphght = tmphght
[
0
]
;
}
return
tmphght;
}
<div
id
=
"demo"
onclick
=
"alert(getComputedHeight('demo'));"
>
hello there
</div>
Reply
incomplete
Tue. Aug. 29th, 2006 11:02 AM
Guerrero
please don't admit snippets without demo and at least simple instructions.
Reply
thank you.good luck
Wed. Apr. 4th, 2007 12:36 AM
sim_louay
too short , but useful
Reply
New Comment
function getComputedHeight(theElt){
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer"){
var is_ie=true;
} else {
var is_ie=false;
}
if(is_ie){
tmphght = document.getElementById(theElt).offsetHeight;
}
else{
docObj = document.getElementById(theElt);
var tmphght1 = document.defaultView.getComputedStyle(docObj, "").getPropertyValue("height");
tmphght = tmphght1.split('px');
tmphght = tmphght[0];
}
return tmphght;
}