- window.onresize:监控屏幕可视区域的变化
- document.documentElement.clientWidth:屏幕可视宽度
- document.documentElement.clientHeight:屏幕可视高度
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>屏幕的可视区域</title> </head> <body> </body> <script type="text/javascript"> window.onload=function (ev) { window.onresize=function (ev1) { console.log(document.documentElement.clientWidth); console.log(document.documentElement.clientHeight); console.log(document.documentElement.clientLeft); console.log(document.documentElement.clientHeight); } } </script> </html>