Document: use JavaScript to obtain the height and width of the current window
< Script Language = "JavaScript" >
VaR S = "" ;
S + = " Visible area width: " + Document. Body. clientwidth;
S + = " <Br> the visible area of the webpage is high: " + Document. Body. clientheight;
S + = " <Br> webpage visible area width: " + Document. Body. offsetwidth + " (Including edges and scroll bars) " ;
S + = " <Br> the visible area of the webpage is high: " + Document. Body. offsetheight + " (Including edges) " ;
S + = " <Br> webpage text width: " + Document. Body. scrollwidth;
S + = " <Br> webpage body: " + Window. screentop;
S + = " <Br> left part of the webpage body: " + Window. screenleft;
S + = " <Br> high screen resolution: " + Window. Screen. height;
S + = " <Br> screen resolution width: " + Window. Screen. width;
S + = " <Br> available workspace height: " + Window. Screen. availheight;
S + = " <Br> available workspace width: " + Window. Screen. availwidth;
S + = " <Br> your screen settings are " + Window. Screen. colordepth + " Bit color " ;
S + = " <Br> set your screen " + Window. Screen. devicexdpi + " Pixel/inch " ;
Document. Write (s );
</ Script >
Code:
< Html >
< Body Onresize = "Myload ()" Onload = "Myload ()" >
< Div ID = "Xuanma" Style = "Z-INDEX: 1; left: 0px; position: absolute; top: 0px" >
< IMG ID = "Ximage" SRC = "Yah/groupimages/060823nhp1.jpg" />
</ Div >
< Script Language = "JavaScript" Type = Text/JavaScript >
Function Myload ()
{
Document. getelementbyid ('x'). style. Top = Document. Body. clientheight / 2 - Document. getelementbyid ('ximage'). Height / 2 ;
Document. getelementbyid ('x'). style. Left = Document. Body. clientwidth / 2 - Document. getelementbyid ('ximage'). Width / 2 ;
}
</ Script >
</ Body >
</ Html >