-->

JavaScript - Window - The Browser Object Model Part 3: Window Properties

Window properties allow access to various browsers and screen details.

Examples and Explanation

Getting Screen Dimensions

console.log(window.screen.width); // Screen width

console.log(window.screen.height); // Screen height

Explanation: The screen property provides information about the user's screen.

Navigating Through History

console.log(window.history.length); // Number of entries in the browsing history

window.history.back(); // Go to the previous page

Explanation: The history object allows navigation within the browser's history.

Location Object

console.log(window.location.href); // Current URL

window.location.reload(); // Reload the current page

Explanation: The location object provides information about and control over the current URL.