Download the X Distribution File.
xHeight(ele[, uH])
// xHeight r8, Copyright 2001-2010 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xHeight(e,h) { var css, pt=0, pb=0, bt=0, bb=0; if(!(e=xGetElementById(e))) return 0; if (xNum(h)) { if (h<0) h = 0; else h=Math.round(h); } else h=-1; css=xDef(e.style); if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') { h = xClientHeight(); } else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) { if(h>=0) { if (document.compatMode=='CSS1Compat') { pt=xGetComputedStyle(e,'padding-top',1); if (pt !== null) { pb=xGetComputedStyle(e,'padding-bottom',1); bt=xGetComputedStyle(e,'border-top-width',1); bb=xGetComputedStyle(e,'border-bottom-width',1); } // Should we try this as a last resort? // At this point getComputedStyle and currentStyle do not exist. else if(xDef(e.offsetHeight,e.style.height)){ e.style.height=h+'px'; pt=e.offsetHeight-h; } } h-=(pt+pb+bt+bb); if(isNaN(h)||h<0) return; else e.style.height=h+'px'; } h=e.offsetHeight; } else if(css && xDef(e.style.pixelHeight)) { if(h>=0) e.style.pixelHeight=h; h=e.style.pixelHeight; } return h; }
By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.
Forum support is available at the X Library Support Forums.
Cross-Browser.com is the home of X - a cross-browser Javascript library, and many demos, applications, articles and documentation.
If you are using X, XC or anything from this site, show off your work by posting a link in the X Showcase forum.