document.body.clientWidth  1004   客户端浏览器的宽度
document.body.clientHeight  598    客户端浏览器的高度

document.body.scrollLeft 0         若有滚动条,则代表距左端的距离
document.body.scrollTop 0         若有滚动条,则代表距上端的距离

document.body.scrollWidth 1004    若有滚动条,滚动条的宽度
document.body.scrollHeight 652     若有滚动条,滚动条的高度

screen.height  取分辨率用
screen.width

测试页面:
<html><head></head><body><input id="btn" type="button" onclick="Test();"/></body><script language='javascript'>
alert(screen.width);
alert(screen.height);
function Test()
{
alert(document.body.clientWidth);
alert(document.body.clientHeight);
}
</script></html>

下面代码是一个例子,在页上走动的小广告


 


        <DIV id="img" style="LEFT: 0px; WIDTH: 99px; POSITION: absolute; TOP: 1582px; HEIGHT: 24px">
            <img src="images\ask.gif" width="50" height="50">
        </DIV>
        <SCRIPT language="JavaScript">
       
      
            var xPos = 20;
            var yPos = document.body.clientHeight;
            var step = 50;
            var delay = 2000;
            var height = 0;
            var Hoffset = 0;
            var Woffset = 0;
            var yon = 0;
            var xon = 0;
            var pause = true;
            var interval;
            img.style.top = yPos;  
                       
           
               
            function changePos() {

                alert(document.body.clientHeight);
                alert(document.body.clientWidth);
                alert(document.body.scrollLeft);
                alert(document.body.scrollTop);
                alert(document.body.scrollWidth);
                alert(document.body.scrollHeight);
               
                //alert(Hoffset);
                //alert(Woffset);
           
                width = document.body.clientWidth;
                height = document.body.clientHeight;
                Hoffset = img.offsetHeight; //不变54
                Woffset = img.offsetWidth; //不变99
                img.style.left = xPos + document.body.scrollLeft;
                img.style.top = yPos + document.body.scrollTop;
              
                if (yon) {
                    yPos = yPos + step;
                } else {
                    yPos = yPos - step;
                }
                if (yPos < 0) {
                    yon = 1;
                    yPos = 0;
                }
                if (yPos >= (height - Hoffset)) {
                    yon = 0;
                    yPos = (height - Hoffset);
                }

                if (xon) {
                    xPos = xPos + step;
                }
                else {
                    xPos = xPos - step;
                }
                if (xPos < 0) {
                    xon = 1;
                    xPos = 0;
                }
                if (xPos >= (width - Woffset)) {
                    xon = 0;
                    xPos = (width - Woffset);
                }
            }

            function start() {
                img.visibility = "visible";
                interval = setInterval('changePos()', delay);
            }
            start();
        </SCRIPT>