เหตุการณ์การปรับขนาดจะทริกเกอร์เมื่อมีการปรับขนาดหน้าต่าง ใช้ window.outerWidth และ window.outerHeight เหตุการณ์ใน JavaScript เพื่อรับขนาดของหน้าต่างเมื่อมีการปรับขนาดเบราว์เซอร์
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อทำงานกับเหตุการณ์ onresize ใน JavaScript
<!DOCTYPE html>
<html>
<head>
<script>
function resizeFunction() {
var val = "Window Width=" + window.outerWidth + ", Window Height=" + window.outerHeight;
document.getElementById("test").innerHTML = val;
}
</script>
</head>
<body onresize="resizeFunction()">
<p>Resize browser window and check the window (browser window) height and width again.</p>
<p id = "test"> </p>
</body>
</html>