JS获取屏幕,浏览器,网页高度宽度
网页可见区域宽:document.body.clientWidth
EX1: CSS:
#bgScreen, #bgIFrame { position: fixed; top: 0; left: 0; z-index: 999; width: 100%; background: #000; filter: alpha(opacity=20); opacity: 0.2; _position: absolute; _top: expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight ); } #bgIFrame { z-index: 998; filter: alpha(opacity=0); opacity: 0; } JS:
$("#bgScreen, #bgIFrame").css("height", jQuery.browser.version == ‘6.0‘ ? window.screen.height - 160 : ‘100%‘);
EX2: JS:
var findDimensions = function() { var winWidth = 0; var winHeight = 0; //获取窗口宽度 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; } return winWidth + "-" + winHeight; } var _height = findDimensions().split("-"); alert(_height[1]);
|
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。