JavaScript Window


The term "Windows" refers to the global object window, which represents the browser window or tab in which your JavaScript code is running. The window object provides access to various properties, methods, and events related to the browser window and its content.


console.log()

The console property in the Window Object represents the browser console that provides the ability to log information and interact with a JavaScript program running in a web page.

Example

Preview

alert()

Displays an alert box with a message and an OK button.

Example

Preview

prompt()

Displays a prompt box with a message, an input field, and OK and Cancel buttons.

Example

Preview

confirm()

Displays a confirmation box with a message, OK and Cancel buttons, and returns a boolean value indicating whether the user clicked OK or Cancel.

Example

Preview

location

Provides information about the current URL and allows scripts to change the current URL.

Example

Preview

document

Represents the HTML document displayed in the window and provides methods for manipulating it.

Example

Preview

innerWidth and innerHeight

Provide the width and height of the content area of the browser window, excluding toolbars and scrollbars.

Example

Preview

scrollTo()

Scrolls the document to the specified position.

Example

Preview

setTimeout()

Executes the function after the specified delay.

Example

Preview

clearTimeout()

Cancels the setTimeout() method called earlier.

Example

Preview

setInterval()

Executes the function repeatedly at the specified interval.

Example

Preview

clearInterval()

Cancels a setInterval() method that was set earlier.

Example

Preview

open()

The open() method is used to open a new browser window or tab programmatically.

Example

Preview

close()

The close() method is used to close the current browser window or tab programmatically. It doesn't require any parameters. However, please note that this method can only close windows that were opened using JavaScript. It cannot close the main browser window or a window/tab that wasn't opened by JavaScript due to security restrictions

Example

Preview

resizeby()

The resizeBy() method is used to resize the current browser window by a specified amount in pixels.

Example

Preview

resizeto()

The resizeTo() method is used to resize the current browser window to a specified width and height.

Example

Preview

scroll()

The scroll() method is used to scroll the content of the current window to a specified position.

Example

Preview

These window object methods provide ways to control the behavior and appearance of the browser window using JavaScript. However, please note that some browser security settings and restrictions may limit the functionality of these methods.