Lecture
Window - window.screen
window.screen provides information about the visual setup of the user's screen.
It's mainly used when you want to know the size or resolution of the current screen or device being used.
Key Properties
-
screen.width: The full width of the screen (in pixels) -
screen.height: The full height of the screen (in pixels) -
screen.availWidth: The available width of the screen excluding the browser -
screen.availHeight: The available height of the screen excluding the browser
Examples
Checking screen width and height
JavaScript
console.log(`The screen width is ${screen.width} pixels.`); console.log(`The screen height is ${screen.height} pixels.`);
Checking available screen size
JavaScript
console.log(`The available screen width is ${screen.availWidth} pixels.`); console.log(`The available screen height is ${screen.availHeight} pixels.`);
Lessons in this chapter · How does JavaScript work in the browser?
- 1. How Do Browsers Work?
- 2. DOM (Document Object Model)
- 3. Browser Window Object
- 4. Window - window.screen
- 5. Window - window.location
- 6. Methods to Select HTML Elements - 1
- 7. How to Select HTML Elements - 2
- 8. Creating and Setting Attributes of HTML Elements
- 9. Events
- 10. Advanced Event Handling
- 11. Multiple-choice quiz
- 12. JSON(JavaScript Object Notation)
- 13. Promise
- 14. Async/Await Handling Asynchronous Processes
- 15. Cookies
- 16. Multiple-choice quiz
- 17. JavaScript Summary
Quiz
0 / 1
What cannot be determined using the window.screen object?
The total width of the screen
The total height of the screen
The version of the browser
The available width of the screen
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help