html页面的三个width: document, window, screen
2013-12-26 21:18
337 查看
Keywords:
document.body.offsetWidth, document.body.offsetHeight,
window.innerWidth, window.innerHeight,
document.documentElement.offsetWidth, document.documentElement.offsetHeight,
screen.width, screen.height
document.body.offsetWidth = 页面内容宽度
window.innerWidth = 浏览器窗口宽度
screen.width = 显示器分辨率宽度
单位均为:px
如果窗口宽度window.innerWidth=800,而内容宽度document.width=960,则页面可能会出现水平滚动条。
分辨率为1280×800的笔记本的screen.width = 1280
var height = 768;
if (window.innerHeight) { //Standard
height = window.innerHeight;
}
else if (document.documentElement.offsetHeight && document.documentElement.offsetHeight > 50) { //IE8 and lower
height = document.documentElement.offsetHeight;
}
else if (document.body && document.body.offsetHeight && document.body.offsetHeight > 50) {
height = document.body.offsetHeight;
}
关于不同浏览器下的窗口宽度,参考: http://www.javascripter.net/faq/browserw.htm
document.body.offsetWidth, document.body.offsetHeight,
window.innerWidth, window.innerHeight,
document.documentElement.offsetWidth, document.documentElement.offsetHeight,
screen.width, screen.height
document.body.offsetWidth = 页面内容宽度
window.innerWidth = 浏览器窗口宽度
screen.width = 显示器分辨率宽度
单位均为:px
如果窗口宽度window.innerWidth=800,而内容宽度document.width=960,则页面可能会出现水平滚动条。
分辨率为1280×800的笔记本的screen.width = 1280
var height = 768;
if (window.innerHeight) { //Standard
height = window.innerHeight;
}
else if (document.documentElement.offsetHeight && document.documentElement.offsetHeight > 50) { //IE8 and lower
height = document.documentElement.offsetHeight;
}
else if (document.body && document.body.offsetHeight && document.body.offsetHeight > 50) {
height = document.body.offsetHeight;
}
关于不同浏览器下的窗口宽度,参考: http://www.javascripter.net/faq/browserw.htm
相关文章推荐
- js获取宽度 ,各种高度宽度document.body.clientWidth , document.body.clientHeight,window.screen.width 等等
- 网页页面中的区域控制 (document.body与window.screen)
- js获取宽度 ,各种高度宽度document.body.clientWidth , document.body.clientHeight,window.screen.width 等等
- window.innerWidth、document.body.clientWidth和html的大小的区别
- double screenWidth = (double)HtmlPage.Window.Eval("screen.Width");
- [转载 js]document.body ,window.screen javascript对象属性取值意义
- HTML:模拟链接被按下,在新标签页打开页面,不使用window.open(可能被拦截)
- jQuery mobile在页面加载时添加加载中效果 document.ready 和window.onload执行顺序比较
- JS 页面加载触发事件 document.ready和window.onload的区别
- 静态页面HTML绑定动态数据.aspx,用document.write的方法!
- 【小白】javascript中的“文档已完成加载后执行 document.write,整个 HTML 页面将被覆盖”
- Html页面Dom对象之Document
- javascript在html中的加载顺序------为什么window.alert(document.getElementById("time").innerTex)无法弹出对话框
- html判断当前页面是否在iframe中/顶级document中
- 拉动滚动条追加内容,无限延伸document高度 $(window).scroll(function(){if($(window).scrollTop() + $(window).height() == $(document).height()) { $("body").append(html) } })
- html/css基础篇——关于浏览器window、document、html、body高度的探究
- html窗口(window)高度、文档(document)高度介绍
- 页面元素坐标和偏移(clientX/pageX/screenX/layerX/offsetWidth/scrollWidth/clientWidth等)相关整理
- 关于浏览器window、document、html、body高度的探究
- 获取页面window/document的值