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
Edit: But that still doesn't fix the window.innerwidth not changing on resize
window.onresize = function(event) {
console.log(window.innerWidth);
};
But it will be called only after resizing is completed.
It should rather be:
window.addEventListener("resize", function() {
console.log(window.innerWidth);
});
This code works in my browser:
<script>
window.onresize = function() {
var widthWin = window.document.body.clientWidth;
console.log(widthWin);
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.