JAVASCRIPT BASICS
- Introduction to JavaScript
- Javascript Features
- JavaScript in HTML
- JavaScript Syntax
- Output in JavaScript
- JavaScript Variables
- Javascript let Keyword
- JS Literals and Keywords
- JavaScript Data Types
- JavaScript Operators
- JavaScript Events
- Javascript const Keyword
JAVASCRIPT FLOW CONTROL AND LOOPS
- JS if, else and else if
- JavaScript for Loop
- JS while and do-while loop
- JS Switch case
- JS break and continue
JAVASCRIPT ADVANCED
- JavaScript Strings
- JavaScript String Methods
- JavaScript Array
- JavaScript Regular Expression
- JavaScript Popup Boxes
- JavaScript Functions
- JavaScript Default Parameters
- JavaScript Rest Parameters
- JavaScript Arrow Function
- JavaScript Errors
- JavaScript Error Handling
- JavaScript Cookies
JAVASCRIPT OBJECT
- JavaScript Objects
- JavaScript User-defined Object
- JavaScript Boolean Object
- JavaScript Number Object
- JavaScript Math Object
- JavaScript Date Object
- JavaScript RegExp Object
JAVASCRIPT WEB API AND INTERFACES
JavaScript Screen is a built-in Interface (object type) that is used to fetch information related to the browser screen on which the current window is rendered.
It provides information about the dimensions of the display screen such as its height, width, color bits, etc.
Since the window object is at the top of the scope chain, the property window.screen
gives the Screen object, but the screen object can be accessed without specifying the window too, in that case JavaScript automatically detects the browser window, which is created by JavaScript Runtime Engine.
Let’s take a simple example to see the working of the screen object.
JS Screen Object Example
JavaScript Screen Object
<script>
document.writeln("Total Height: " + screen.height +"<br>");
document.writeln("Total Width: " + screen.width +"<br>");
</script>
</body>
JavaScript Screen Object Properties
JavaScript Screen object includes some properties that are used to get browser screen information. A table of such properties is given below.
Property | Description |
---|---|
availHeight | specifies the height of screen, excluding the windows taskbar |
availWidth | specifies the width of the screen, excluding the Windows taskbar |
colorDepth | specifies the depth of color palette, in bits, to display images |
height | specifies the total height of the screen |
pixelDepth | specifies the color Resolution, in bits per pixel, of the screen |
width | specifies the total width of the screen |
The Screen object colorDepth property is the number of bits used to represent the color of a single pixel. It returns the bit depth of the color palette for displaying images.
JavaScript Screen Object Methods
There are no direct methods in the Screen method object.
Uses of Screen Object
The JavaScript Screen object can be used for improving the user experience by controlling the UI of the web app or website based on the screen size.
3 thoughts on “JavaScript Screen Object”