1

When i resize the window, the window.innerwidth doesn't update. I dont want to use jQuery.

var page = window.innerWidth;
var content = document.getElementById("content");
content.style.width = page - 300 + "px";

i tried:

window.addEvent("resize", function() {
  console.log(window.getCoordinates().width);
});

with no avail​</p>

Edit: But that still doesn't fix the window.innerwidth not changing on resize

4

3 回答 3

1

它应该是:

window.addEventListener("resize", function() {
    console.log(window.innerWidth);
});
于 2012-09-18T14:57:24.127 回答
0

此代码适用于我的浏览器:

<script>

    window.onresize = function() {    
        var widthWin = window.document.body.clientWidth;
        console.log(widthWin);         
    }

</script>
于 2014-04-02T22:56:35.317 回答
0
window.onresize = function(event) {
  console.log(window.innerWidth);
};

但只有在调整大小完成后才会调用它。

于 2012-09-18T14:55:37.660 回答