Screen width Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Screen

Description

The width property returns the total width of the user's screen, in pixels.

Return Value

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:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials