screen | NN 4 IE 4 DOM n/a | |||||||||||||||
The screen object refers to the video display on which the browser is being viewed. Many video control panel settings influence the property values, but only a handful of properties are shared among browser brands. |
||||||||||||||||
Object Model Reference | ||||||||||||||||
|
||||||||||||||||
Object-Specific Properties | ||||||||||||||||
|
||||||||||||||||
Object-Specific Methods | ||||||||||||||||
None. |
||||||||||||||||
Object-Specific Event Handler Properties | ||||||||||||||||
None. |
availHeight, availWidth | NN 4 IE 4 DOM n/a |
Read-only | |
Provide the height and width of the content region of the user's video monitor in pixels. This measure does not include the 24-pixel task bar (Windows) or 20-pixel system menubar (Macintosh). IE/Macintosh miscalculates the height of the menu bar as 24 pixels. To use these values in creating a pseudo-maximized window, you also have to adjust the top-left position of the window. |
|
Example | |
var newWind = window.open("","","height=" + screen.availHeight + ",width=" + screen.availWidth) |
|
Value | |
Integer of available pixels in vertical and horizontal dimensions. |
|
Default | |
Depends on the user's monitor size. |
availLeft, availTop | NN 4 IE n/a DOM n/a |
Read-only | |
Provide the pixel coordinates of the left and top edges of the screen that is available for content. With the standard Windows Taskbar arrangement, both values are zero. But drag the Taskbar to the left or top of the screen, and the corresponding value increases to accommodate the bar's space. Navigator 4 for the Macintosh doesn't start its screen counting until just below the fixed menu bar, but for Netscape 6, the availTop property returns 20 for the menu bar height. |
|
Example | |
window.moveTo(screen.availLeft, screen.availTop); |
|
Value | |
Integer. |
|
Default | |
0 (Windows); 20 (Macintosh) |
bufferDepth | NN n/a IE 4 DOM n/a |
Read/Write | |
Specifies the setting of the offscreen bitmap buffer. Path animation smoothness may improve on some clients if you match the bufferDepth to the colorDepth values. Setting the bufferDepth to -1 forces IE to buffer at the screen's pixel depth (as set in the control panel), and colorDepth is automatically set to that value, as well (plus if a user changes the bits per pixel, the buffer is adjusted accordingly). A setting to any of the other permitted values (1, 4, 8, 15, 16, 24, or 32) buffers at that pixel depth and sets the colorDepth to that value. The client's display must be set to the higher bits-per-pixel values to take advantage of the higher settings in scripts. |
|
Example | |
screen.bufferDepth = 4; |
|
Value | |
Any of the following allowed integers: -1 | 0 | 4 | 8 | 15 | 16 | 24 | 32. |
|
Default | |
0 |
colorDepth | NN 4 IE 4 DOM n/a |
Read-only | |
Returns the number of bits per pixel used to display color in the video monitor or image buffer. Although this property is read-only, its value can be influenced by settings of the bufferDepth property (IE only). You can determine the color depth of the current video screen and select colors accordingly. |
|
Example | |
if (screen.colorDepth > 8) { document.getElementById("pretty").color = "cornflowerblue"; } else { document.getElementById("pretty").color = "blue"; } |
|
Value | |
Integer. |
|
Default | |
Current video control panel setting. |
deviceXDPI, deviceYDPI, logicalXDPI, logicalYDPI | NN n/a IE 6(Win) DOM n/a |
Read-only | |
All four properties concern themselves with the dots-per-inch resolution of display screens along the horizontal (x) and vertical (y) axes. A device density property returns the actual pixel density of the current display screen, as detected by the operating system. The logical density is the "normal" pixel density that most users and page authors work with (typically 96 dots per inch horizontally and vertically). These two sets of properties let scripts examine whether the user has a higher-than-usual pixel density display, which could make fixed-size items, such as images and pixel-sized fonts, appear uncomfortably small on the screen. In such cases, scripts can determine a scaling factor between the device and logical densities, and apply that factor to the style.zoom property of critical elements (or the entire document.body, for that matter). Users of high-density display systems may already have their IE application preferences set to automatic scaling, so these calculations aren't necessary. |
|
Example | |
var normDPI = 96; if ((screen.deviceXDPI == screen.logicalXDPI) && (screen.deviceXDPI > normDPI)) { document.body.style.zoom = normDPI / screen.logicalXDPI; } |
|
Value | |
Integer. |
|
Default | |
96 |
fontSmoothingEnabled | NN n/a IE 4(Win) DOM n/a |
Read-only | |
Returns Boolean true if the user has enabled Smooth Edges for fonts in the Windows Display control panel. The setting may influence the font-related style sheet you link into a document. |
|
Example | |
var styleFile = "css/corpStyle.css"; if (screen.fontSmoothingEnabled) { styleFile = "css/corpStyleFancy.css"; } document.write("<link type='text/css' rel='stylesheet' href='" + styleFile + "'>"); |
|
Value | |
Boolean value: true | false. |
|
Default | |
false |
height, width | NN 4 IE 4 DOM n/a |
Read-only | |
Return the number of pixels available vertically and horizontally in the client video monitor. This is the raw dimension. For the amount of screen space not covered by system bars, see availHeight and availWidth. |
|
Example | |
if (screen.height > 480 && screen.width > 640) { ... } |
|
Value | |
Integer of pixel counts. |
|
Default | |
Depends on video monitor. |
logicalXDPI, logicalYDPI | |
See deviceXDPI. |
pixelDepth | NN 4 IE n/a DOM n/a |
Read-only | |
Returns the number of bits per pixel used to display color in the video monitor. This value is similar to the colorDepth property, but it is not influenced by a potential custom color palette, as colorDepth is. |
|
Example | |
if (screen.pixelDepth > 8) { document.getElementById("pretty").color = "cornflowerblue"; } else { document.getElementById("pretty").color = "blue"; } |
|
Value | |
Integer. |
|
Default | |
Current video control panel setting. |
updateInterval | NN n/a IE 4 DOM n/a |
Read/Write | |
Provides the time interval (in milliseconds) between screen updates. A value of zero lets the browser select an average that usually works best. The longer the interval, the more animation steps may be buffered and then ignored as the update fires to display the current state. |
|
Example | |
screen.updateInterval = 0; |
|
Value | |
Positive integer or zero. |
|
Default | |
0 |
width | |
See height. |