Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Handling the Resize Event</title> </head> <body> <p id="result"></p> <script> function displayWindowSize(){ var w = window.outerWidth; var h = window.outerHeight; var txt = "Window size: width=" + w + ", height=" + h; document.getElementById("result").innerHTML = txt; } window.onresize = displayWindowSize; </script> <p><strong>Note:</strong> Resize the browser window to see how the resize event works.</p> </body> </html>