扫码关注官方订阅号
好像是用bom里的一些知识 记不太清了
window.onresize = function(){ console.log(window.innerWidth); console.log(window.innerHeight); }
你是说文档自适应窗口的大小么,用window.innerwidth window.innerHeight
说清楚如何变化?是缩小窗口,还是滑动滚动条?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <style> body { height: 2000px; } #p1{ position:fixed; top:0; left: 0; } </style> <body> <p id="p1"></p> </body> <script> var temer; timer = setInterval(function () { var l = "文档的宽度:" + document.body.clientWidth + ", 文档的高度:" + document.body.clientHeight + ", 当前页面的宽度:" + document.documentElement.clientWidth + ", 当前页面的宽度:" + document.documentElement.clientHeight + ", 向下滑动的距离:" + document.body.scrollTop; document.getElementById("p1").innerHTML = l; }, 1000); </script> </html>
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
你是说文档自适应窗口的大小么,用window.innerwidth window.innerHeight
说清楚如何变化?是缩小窗口,还是滑动滚动条?