Javascript examples for Browser Object Model:Screen
The width property returns the total width of the user's screen, in pixels.
A Number, representing the total width of the user's screen, in pixels
The following code shows how to get the total width of your screen:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w. j av a 2 s .c o m*/ var x = "Total Width: " + screen.width + "px"; document.getElementById("demo").innerHTML = x; } </script> </body> </html>