[英]DIV offsetWidth/Width/innerWidth returns zero in IE8 when window resizing
我的页面中有很多元素。 请考虑以下DIV
<div id="root">
..................
<div id="child1">
.............
</div>
<div id="child2">
...............
</div>
</div>
根div(#root)在加载时会根据内容具有一定的宽度。
当窗口调整大小时,将调用repaint()函数,该函数存在于窗口调整大小函数中
$(window).resize( function () {
repaint();
});
function repaint(){
//width returns "0" in IE8 browser and other browsers working fine
var width=$("#root").width() || $("#root").innerWidth() -> returns zero value in IE8
}
在IE8浏览器中返回宽度为“ 0”,但在IE9 /其他现代浏览器中返回宽度(960px)。
我不知道此问题的确切原因是什么。
为什么在调整窗口大小时返回零宽度。
谢谢,
西瓦
这在IE8中有效。 参见控制台(布局已完成)。
$(window).resize( function () {
repaint();
});
function repaint(){
//width returns "0" in IE8 browser and other browsers working fine
var width=$("#root").width();
console.log(width);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.