jQuery 获取屏幕高度、宽度
2015-06-11 23:16
501 查看
jQuery 获取屏幕高度、宽度 做手机Web开发做浏览器兼容用到了,所以在网上找了些汇总下。 alert($(window).height()); //浏览器当前窗口可视区域高度 alert($(document).height()); //浏览器当前窗口文档的高度 alert($(document.body).height());//浏览器当前窗口文档body的高度 alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin alert($(window).width()); //浏览器当前窗口可视区域宽度 alert($(document).width());//浏览器当前窗口文档对象宽度 alert($(document.body).width());//浏览器当前窗口文档body的高度 alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin // 获取页面的高度、宽度 function getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else { if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if (document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else { if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else { if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } } } // for small pages with total height less then height of the viewport if (yScroll < windowHeight) { pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if (xScroll < windowWidth) { pageWidth = xScroll; } else { pageWidth = windowWidth; } arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight); return arrayPageSize; } // 滚动条 document.body.scrollTop; $(document).scrollTop();
jQuery 获取屏幕高度、宽度
相关文章推荐
- jQuery map vs. each作者该解法对吗?
- Jquery ajax方法解析返回的json数据
- JQuery学习系列2--选择器
- jQuery jcrop插件截图使用方法
- Jquery pagination 简单应用
- jquery初步(二) 选择器
- jquery的$().each,$.each
- jqueryUI的拖动说明
- php+jquery+ajax+json简单小例子
- jQuery选择器全面总结
- jQuery时间验证和转换为标准格式的时间
- jquery sticky停靠在右下角的插件 ,jquery pushytip提示框显示插件
- JQuery中$.ajax()方法参数详解
- JQuery学习系列1
- jquery页面刷新和返回页面
- jQuery lazyload插件详解和问题解答
- 基于jQuery鼠标悬停上下滑动导航条
- jQuery i18n国际化
- jQuery操控DOM元素
- ie8下jquery改变PNG的opacity出现黑边