2014年5月6日 星期二

JavaScript Browser Heihgt Width

$(document).ready(function () {


                var s = "";

                s += " 網頁可見區域寬:" + document.body.clientWidth;

                s += "<br> 網頁可見區域高:" + document.body.clientHeight;

                s += "<br> 網頁可見區域寬:" + document.body.offsetWidth + " (包括邊線和捲軸的寬)";

                s += "<br> 網頁可見區域高:" + document.body.offsetHeight + " (包括邊線的寬)";

                s += "<br> 網頁正文全文寬:" + document.body.scrollWidth;

                s += "<br> 網頁正文全文高:" + document.body.scrollHeight;

                s += "<br> 網頁被卷去的高(ff):" + document.body.scrollTop;

                s += "<br> 網頁被卷去的高(ie):" + document.documentElement.scrollTop;

                s += "<br> 網頁被卷去的左:" + document.body.scrollLeft;

                s += "<br> 網頁正文部分上:" + window.screenTop;

                s += "<br> 網頁正文部分左:" + window.screenLeft;

                s += "<br> 螢幕解析度的高:" + window.screen.height;

                s += "<br> 螢幕解析度的寬:" + window.screen.width;

                s += "<br> 螢幕可用工作區高度:" + window.screen.availHeight;

                s += "<br> 螢幕可用工作區寬度:" + window.screen.availWidth;

                s += "<br> 你的螢幕設置是 " + window.screen.colorDepth + " 位彩色";

                s += "<br> 你的螢幕設置 " + window.screen.deviceXDPI + " 像素/英寸";

                //alert (s);
                document.getElementById('show').innerHTML = s;

            });

       window.onscroll = J_Modify;
       function J_Modify() {
            var obj = document.getElementById('AB');

            obj.style.top = document.body.scrollTop + 200 + 'px';
            obj.style.left = (document.body.clientWidth - obj.clientWidth) / 2 + 'px';


        }