Javascript screen width property returns the width of display screen. width property of javascript screen object actually returns the number of pixels in horizontal direction i.e. horizontal value for screen resolution along x-axis. Javascript screen object width property depends upon the screen resolution of client system. For example if screen resolutions of client’s PC is 800 X 600 then it represents the width as 800 pixels in a single horizontal row along x-axis and width property of javascript screen object returns the value equal to 800. You can see the screen resolution property in the display properties of the computer system that can be accessed by right clicking on desktop and selecting the properties from the menu or by selecting Display icon in the control panel. Display properties dialog box shows the tabs for different types of display settings such as wallpaper, screensaver, themes, appearance and settings. In the settings tab you can see the current value of screen resolutions.

Syntax for Javascript screen width property

screen.width

or

window.screen.width

You can use any of the above syntax to access the javascript screen width property.

Examples of Javascript screen width property

<script type="text/javascript" language="javascript">
    document.write(screen.width);

    document.write("<br />");

    document.write(window.screen.width);
</script>

Continue to next tutorial: Javascript Window Screen Object to get information about all the properties of JavaScript Screen object.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.