<!doctype html> <html> <head> <meta charset="utf-8"> <title>[JavaScript] Width of Browser Window in Pixel</title> </head> <body> <div id="width" style="width: 100%"> </div> <div id="info"></div> <script type="text/javascript"> var width = document.getElementById("width").offsetWidth; document.getElementById('info').innerHTML = 'The width of browser window is ' + width + ' pixels.'; document.getElementById("width").parentNode.removeChild(document.getElementById("width")); </script> </body> </html>