js實時監聽窗口變化總結

<script>瀏覽器

window.onresize = function () {ide

var Width = window.innerWidth//瀏覽器窗口的內部寬度(包括滾動條)ip

|| document.documentElement.clientWidthit

|| document.body.clientWidth;io

var Height = window.innerHeight//瀏覽器窗口的內部高度(包括滾動條)console

|| document.documentElement.clientWidthfunction

|| document.body.clientHeight;class

console.log(Width, Height);cli

}di

</script>

相關文章
相關標籤/搜索