适用所有浏览器
1 2 var  w = window .innerWidth || document .documentElement.clientWidth || document .body.clientWidth;var  w = window .innerHeight || document .documentElement.clientHeight || document .body.clientHeight;
有三种方法能够确定浏览器窗口的尺寸(浏览器的视口,不包括工具栏和滚动条)。
对于Internet Explorer9、Chrome、Firefox、Opera 以及 Safari:
1 2 window .innerHeight; window .innerWidth; 
对于 ie 8、7、6、5:
1 2 3 4 5 document .documentElement.clientHeightdocument .documentElement.clientWidthdocument .body.clientHeightdocument .body.clientWidth
获取页面总高度和宽度,以及scrollTop d的兼容处理;
1 2 3 4 5 6 7 8 9 10 11 function  getClient (    return  {         width: window .innerWidth || document .documentElement.clientWidth || document .body.clientWidth,         height: window .innerHeight || document .documentElement.clientHeight || document .body.clientHeight     } } function  getScrollTop (    return  window .pageYOffset || document .documentElement.scrollTop; } 
获取元素的宽高
1 2 3 4 5 document .getElementById("div" ).offsetHeight; document .getElementById("div" ).offsetWidth;  document .getElementById("div" ).offsetLeft;  document .getElementById("div" ).offsetTop