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>
posted @ 2017-08-20 23:53  wood2012  阅读(1108)  评论(0编辑  收藏  举报