[英]IE7 viewport dimensions including scrollbars
My definition of "viewport" is everything between the browser's borders (visible area + scrollbar) 我对“视口”的定义是浏览器边界(可见区域+滚动条)之间的所有内容
http://xirc.chez.com/ie7.html http://xirc.chez.com/ie7.html
As you can see, I tried: 如您所见,我尝试过:
The Internet Explorer 7 bug per say is that offset* and getBoundingClientRect() do not include the scrollbar 每个人说的Internet Explorer 7错误是offset *和getBoundingClientRect()不包含滚动条
Hide the scrollbar, get the width/height in the next line of code and show the scrollbar again. 隐藏滚动条,在下一行代码中获取宽度/高度,然后再次显示滚动条。
// Hide scrollbars
document.body.style.overflow = "hidden";
// Get width/height
var width = document.body.offsetWidth;
// Reset scrollbars before the UI repaints
document.body.style.overflow = "";
alert(width);
//-> 1600 (on my display)
This will all happen before the display gets updated, so the scrollbars won't flicker and you'll have the full dimensions. 这都将在更新显示之前发生,因此滚动条不会闪烁,您将拥有完整的尺寸。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.