You are here: Reference > JavaScript > client-side > browser > objects > screen

screen object

Browser support:
Contains information about the dimensions of the screen and the display settings.
If you need the placement of the browser window on the screen, use the outerWidth, outerHeight and the screenX, screenY properties of the window object.

Syntax:

Properties that reference the object:
window.screen
The base interface, through which you can add new functionalities to the screen object, is the Screen interface.

Possible members:

Properties:
availHeight
Returns the height of the area on the screen that is available for application windows.
availLeft
Returns the left side of the area on the screen that is available for application windows.
availTop
Returns the top side of the area on the screen that is available for application windows.
availWidth
Returns the width of the area on the screen that is available for application windows.
bufferDepth
Sets or retrieves the number of bits used to represent the color of a single pixel in the off-screen bitmap buffer.
colorDepth
Retrieves the number of bits used to represent the color of a single pixel on the screen or in the buffer when off-screen buffering is allowed.
deviceXDPI
Returns the current number of dots per inch (DPI) of the document's viewport along the horizontal (x) axis.
deviceYDPI
Returns the current number of dots per inch (DPI) of the document's viewport along the vertical (y) axis.
fontSmoothingEnabled
Returns a Boolean value that indicates whether font smoothing is enabled.
height
Returns the vertical resolution of the display screen, in pixels.
left
Retrieves the horizontal offset of top-left corner of the current screen relative to the top-left corner of the main screen, in pixels.
logicalXDPI
Returns the number of dots per inch (DPI) of the document's viewport along the horizontal (x) axis at normal zoom level.
logicalYDPI
Returns the number of dots per inch (DPI) of the document's viewport along the vertical (y) axis at normal zoom level.
pixelDepth
9
Retrieves the number of bits used to represent the color of a single pixel on the screen or in the buffer when off-screen buffering is allowed.
systemXDPI
8
Returns the number of dots per inch (DPI) of the display screen along the horizontal (x) axis at normal zoom level.
systemYDPI
8
Returns the number of dots per inch (DPI) of the display screen along the horizontal (x) axis at normal zoom level.
top
Retrieves the vertical offset of the top-left corner of the current screen relative to the top-left corner of the main screen, in pixels.
updateInterval
Specifies or returns the time interval (in milliseconds) between screen updates.
width
Returns the horizontal resolution of the display screen, in pixels.

Example HTML code 1:

This example illustrates the use of the screen object:
<head>
    <script type="text/javascript">
        function GetDimensions () {
            var scrLeft = document.getElementById ("scrLeft");
            scrLeft.innerHTML = screen.left;
            var scrTop = document.getElementById ("scrTop");
            scrTop.innerHTML = screen.top;
            var scrWidth = document.getElementById ("scrWidth");
            scrWidth.innerHTML = screen.width;
            var scrHeight = document.getElementById ("scrHeight");
            scrHeight.innerHTML = screen.height;


            var availLeft = document.getElementById ("availLeft");
            availLeft.innerHTML = screen.availLeft;
            var availTop = document.getElementById ("availTop");
            availTop.innerHTML = screen.availTop;
            var availWidth = document.getElementById ("availWidth");
            availWidth.innerHTML = screen.availWidth;
            var availHeight = document.getElementById ("availHeight");
            availHeight.innerHTML = screen.availHeight;
        }
    </script>
</head>
<body onload="GetDimensions ();">
    <h3>Dimensions of the screen:</h3>
    Left: <span id="scrLeft"></span><br />
    Top: <span id="scrTop"></span><br />
    Width: <span id="scrWidth"></span><br />
    Height: <span id="scrHeight"></span><br />

    <h3>Dimensions of the available area:</h3>
    Left: <span id="availLeft"></span><br />
    Top: <span id="availTop"></span><br />
    Width: <span id="availWidth"></span><br />
    Height: <span id="availHeight"></span><br />
</body>
Did you find this example helpful? yes no

External links:

User Contributed Comments

Post Content

Post Content