window.onresize使用实例

<!DOCTYPE html>
<html>
<head>
    <title>请调整浏览器窗口</title>
    <meta charset="UTF-8">
</head>
<body>
    <h2 align="center">请调整浏览器窗口大小</h2>
    <hr>
    <form action="#" method="get" name="form1" id="form1">
        <!-- 显示浏览器窗口的实际尺寸 -->
        浏览器窗口的实际高度: <input  id="height" type="text" name="availHeight" size="4"><br> 
        浏览器窗口的实际宽度: <input  id="width"  type="text" name="availWidth"  size="4"><br>
    </form>

    <script>
        document.getElementById('height').value = window.outerHeight + "px";
        document.getElementById('width').value = window.outerWidth + "px";

        window.onresize=function(){
            document.getElementById('height').value = window.outerHeight + "px";
            document.getElementById('width').value = window.outerWidth + "px";
        };
    </script>
</body>
</html>
原文地址:https://www.cnblogs.com/wood2012/p/7896572.html