获取页面的范围

var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    var clientWidth;
    if (window.innerWidth) {
        clientWidth = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
    } else {
        clientWidth = document.documentElement.clientWidth;
    }
    var clientHeight;
    if (window.innerHeight) {
        clientHeight = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
    } else {
        clientHeight = document.documentElement.clientHeight;
    }        
         obj.style.position = 'absolute';
        obj.style.zIndex=999;
        obj.style.display='block';
        obj.style.left = scrollLeft+((clientWidth-a.offsetWidth)/2)+'px';
       obj.style.top = scrollTop+((clientHeight-a.offsetHeight)/2)+'px';
posted on 2007-06-28 12:05  西湖浪子  阅读(181)  评论(0)    收藏  举报