Java Script


JavaScript Tutorial


Admission Enquiry Form


Screen object in Javascript

In JavaScript, object is the container of properties/variables and methods/functions. Screen is the object which contains some properties and methods to perform some screen related functions.

Screen object properties and methods

screen.availHeight property in JavaScript

The availHeight property returns the height of the user's screen, in pixels, minus interface features like the Windows Taskbar.

var x = "Available Height: " + screen.availHeight;




Example of screen.availHeight property

<html>
<head>
<title>screen object availHeight property</title>
<script>
function aheight() {
var x = "Available Height: " + screen.availHeight + "px";
alert(x);
}
</script>
</head>
<body>

<p>Click the button to display the available height of your screen.</p>
<input type="button" value="availHeight" onclick="aheight()"/>
</body>
</html>






screen.availWidth property in JavaScript

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

var w = "Available Width: " + screen.availWidth;





Example of screen.availWidth property

<html>
<head>
<title>screen object availWidth property</title>
<script>
function aWidth() {
var w = "Available width: " + screen.availWidth + "px";
alert(w);
}
</script>
</head>
<body>

<p>Click the button to display the available width of your screen.</p>
<input type="button" value="availWidth" onclick="aWidth()"/>
</body>
</html>