Learn Dynamic HTML With JS
Lesson 1 - HTML JS Relationship
Lesson 2 - HTML DOM
Lesson 4 - Basic Interaction
Lesson 5 - Manipulating CSS
Lesson 6 - HTTP Requests
Lesson 7 - Form Handling
The window
object provides methods and properties to control the browser window. All global JavaScript objects, functions, and variables automatically become members of this window
object.
Here are some common window
properties and methods:
window.alert()
: Displays an alert dialog with a message.alert('Hello, world!');
window.console
: Provides access to the browser's console for logging information.console.log('This is a log message.');
window.innerHeight
and window.innerWidth
: Get the inner height and width of the window.const height = window.innerHeight; const width = window.innerWidth; console.log(`Height: ${height}, Width: ${width}`);
window.open()
: Opens a new browser window or tab.window.open('https://www.example.com', '_blank');
window.close()
: Closes the current window.window.close();
These examples demonstrate how to use various window
object properties and methods in JavaScript to interact with the browser window and its environment.