Width and height of the viewable area: clientwidth, clientheight
Scrolling Distance: scrolltop
Actual height of content: scrollheight
HTML code:
<Bodystyle= "height:2000px;"> <DivID= "Div1"style= "width:100px; height:100px; border:1px solid red; padding:10px; margin:10px;"> <Divstyle= "width:100px; height:600px; background: #ccc;"></Div> </Div></Body>
JS Code:
//width and height of the viewable area //alert (document.documentElement.clientWidth); //alert (document.documentElement.clientHeight); //Scrolling DistanceDocument.onclick =function(){ //alert (DOCUMENT.DOCUMENTELEMENT.SCROLLTOP); ie/Firefox support //alert (DOCUMENT.BODY.SCROLLTOP); Chrome only support varscrolltop = Document.documentElement.scrollTop | |Document.body.scrollTop; //alert (scrolltop); //scrollheight: Content actual width high varOdiv = document.getElementById (' Div1 ')); alert (odiv.scrollheight); };
Javascript--bom the size of the window