CancelImage Upload

Returning a display screen's available width and height minus taskbar in JavaScript

To find out the available width and height of a users screen, taking away the space taken up by the Operating System's taskbar, the following JavaScript code can be used:

var width = screen.availWidth + "px";

var height = screen.availHeight + "px";

The difference here to returning the screens total width and height of course is the avail (short for available) in front of width and height. Here is a more detailed example with the result being loaded into a span tag via getElementById():

<title>Screen Available Width and Height</title>

<script language="JavaScript">

function dimensions()

       var dimensions = document.getElementById("dimensions");

       var width = "Available Width: " + screen.availWidth + "px";

       var height = "Available Height: " + screen.availHeight + "px";

       dimensions.innerHTML = width + "<br>" + height;



<body onload="javascript:dimensions();">

<span id="dimensions"></span>


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •