查找视口高度/宽度,交叉浏览器:
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查找视口高度/宽度,交叉浏览器:相关的知识,希望对你有一定的参考价值。
A little bit of browser detection and some functions to get the viewport height and width, crossbrowser.
browser : { IE : !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1), Opera : navigator.userAgent.indexOf('Opera') > -1, WebKit : navigator.userAgent.indexOf('AppleWebKit/') > -1, Gecko : navigator.userAgent.indexOf('Gecko') > -1 getViewHgt : function(){ return browser.IE ? // IE Cases // Test for IE 5-7 Quirks and IE 4 (!(document.documentElement.clientHeight) || (document.documentElement.clientHeight === 0)) ? // IE 5-7 Quirks and IE 4 case document.body.clientHeight : //IE 6+ Strict Case document.documentElement.clientHeight: // Gecko and Other DOM compliant case window.innerHeight; }, getViewWdth : function(){ return browser.IE ? // IE Cases // Test for IE 5-7 Quirks and IE 4 (!(document.documentElement.clientWidth) || (document.documentElement.clientWidth === 0)) ? // IE 5-7 Quirks and IE 4 case document.body.clientWidth : //IE 6+ Strict Case document.documentElement.clientWidth: // Gecko and Other DOM compliant case window.innerWidth; }
以上是关于查找视口高度/宽度,交叉浏览器:的主要内容,如果未能解决你的问题,请参考以下文章
JavaScript 查找视口高度/宽度,crossbrowser: