Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Get Browser Viewport Dimensions</title> </head> <body> <script> function windowSize(){ let w = window.innerWidth; let h = window.innerHeight; alert("Width: " + w + ", " + "Height: " + h); } </script> <button type="button" onclick="windowSize();">Get Window Size</button> </body> </html>