JSは画面解像度とウィンドウサイズを取得します.

13797 ワード

       :document.body.clientWidth 
       :document.body.clientHeight 
       :document.body.offsetWidth (      ) 
       :document.body.offsetHeight (      ) 
       :document.body.scrollWidth 
       :document.body.scrollHeight 
       :document.body.scrollTop 
       :document.body.scrollLeft 
       :window.screenTop 
       :window.screenLeft 
       :window.screen.height
       :window.screen.width
         :window.screen.availHeight
         :window.screen.availWidth
 
      :window.innerWidth
      :window.innerHeight
 
HTML    :scrollLeft,scrollWidth,clientWidth,offsetWidth 
scrollHeight:          。 
scrollLeft:                                
scrollTop:                              
scrollWidth:          
offsetHeight:               offsetParent             
offsetLeft:            offsetParent                 
offsetTop:            offsetTop                 
event.clientX           
event.clientY           
event.offsetX           
event.offsetY           
document.documentElement.scrollTop          
event.clientX+document.documentElement.scrollTop          +         
 
IE,FireFox     : 
 
IE6.0、FF1.06+: 
clientWidth = width + padding 
clientHeight = height + padding 
offsetWidth = width + padding + border 
offsetHeight = height + padding + border 
 
IE5.0/5.5: 
clientWidth = width - border 
clientHeight = height - border 
offsetWidth = width 
offsetHeight = height 
 
(     :CSS  margin  , clientWidth、offsetWidth、clientHeight、offsetHeight   )
       : document.body.clientWidth
       : document.body.clientHeight
       : document.body.offsetWidth (      )
       : document.body.offsetHeight (      )
       : document.body.scrollWidth
       : document.body.scrollHeight
       : document.body.scrollTop
       : document.body.scrollLeft
       : window.screenTop
       : window.screenLeft
       : window.screen.height
       : window.screen.width
         : window.screen.availHeight
         : window.screen.availWidth
-------------------
    
         Document           ,              。
        ,        ,            :           , Netscape     Window   ; IE      Document   body    ; DOM   ,         ,          ,     。
Window   innerWidth             。Window   innerHeight             。
Document   body    HTML     。Document   documentElement     HTML      。
document.body.clientHeight  HTML           。document.body. clientWidth  HTML           。
 
    

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>        title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
head>
<body>
<h2 align="center">          h2><hr>
<form action="#" method="get" name="form1" id="form1">

            : <input type="text" name="availHeight" size="4"><br>
            : <input type="text" name="availWidth" size="4"><br>
form>
<script type="text/javascript">
<!-- 
var winWidth = 0;
var winHeight = 0;
function findDimensions() //  :    
{
//      
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
//      
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
//    Document   body    ,      
if (document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}
//          
document.form1.availHeight.value= winHeight;
document.form1.availWidth.value= winWidth;
}
findDimensions();
//    ,    
window.onresize=findDimensions;
//-->
script>
body>
html>