JavaScript provides several methods that can be used to interact with the browser's window object, which represents the current web page. Here are some common window methods:
window.alert(): This method displays an alert box with a message and an OK button. It can be used to display a message to the user, or to prompt the user for input.
window.confirm(): This method displays a confirm box with a message and OK and Cancel buttons. It can be used to get confirmation from the user before performing an action.
window.prompt(): This method displays a prompt box with a message, a text field for input, and OK and Cancel buttons. It can be used to get input from the user.
window.open(): This method opens a new window or a new tab with the specified URL. It can be used to open a new web page or to open a new window with a different size and position.
window.close(): This method closes the current window or tab. It can be used to close a window that was opened using thewindow.open()method.
window.innerWidthandwindow.innerHeight: These properties return the width and height of the browser window's viewport (the area of the window that displays the web page), in pixels.
window.outerWidthandwindow.outerHeight: These properties return the width and height of the browser window, including the browser's chrome (e.g. toolbars and scrollbars), in pixels.
window.scrollXandwindow.scrollY: These properties return the number of pixels that the current document has been scrolled horizontally and vertically.
window.location: This property can be used to get the current URL of the web page and change it programmatically, it also allows you to redirect the user to another page.
window.history: This property can be used to work with the browser's history, you can go back and forward in the browser history, or you can change the URL displayed in the browser's address bar without loading a new page.
window.setTimeout(function, delay): This method sets a timer that executes a function after a specified delay, in milliseconds. It can be used to schedule a function to be executed after a certain period of time.
window.clearTimeout(timer): This method cancels a timeout that was set using thesetTimeout()method.
window.setInterval(function, delay): This method sets a timer that repeatedly executes a function after a specified delay, in milliseconds. It can be used to schedule a function to be executed periodically.
window.clearInterval(timer): This method cancels an interval that was set using thesetInterval()method.
window.screen: This property provides information about the user's screen, such as the screen's resolution, color depth, and available screen size.
window.navigator: This property can be used to get information about the user's browser and its capabilities, such as the browser name and version, the platform, and supported languages.
window.matchMedia(): This method allows you to check if the current browser window matches a specified media query.
window.getSelection(): This method returns a Selection object representing the current text selection in the document.
window.performance: This property provides a Performance object that can be used to measure the performance of your web application and understand how long it takes to load, render and execute your javascript.
Â

