The height
property returns the total height of the user's screen in pixels.
height |
Yes | Yes | Yes | Yes | Yes |
screen.height
A Number type value representing the total height of the user's screen, in pixels.
The following code shows how to get the total height of your screen.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--from www. ja va 2 s .com-->
<script>
function myFunction() {
var x = "Total Height: " + screen.height + "px";
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
All screen properties in one example
<!DOCTYPE html>
<html>
<body>
<div id="demo"></div>
<script>
var txt;
txt = "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
txt+= "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight + "</p>";
txt+= "<p>Color depth: " + screen.colorDepth + "</p>";
txt+= "<p>Color resolution: " + screen.pixelDepth + "</p>";
<!--from w ww. j av a 2s. com-->
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
The code above is rendered as follows: