The JavaScript window object represents the browser window or tab that contains the current document. In a normal browser script it is also the global object, so many APIs such as alert(), setTimeout(), and location are available through it.
console.log(window.innerWidth);
window.alert("Hello from the current window");
Modern browsers deliberately restrict some window operations. Opening, focusing, moving, resizing, or closing windows may only work in specific situations, especially when a script did not create the window.
| Method / topic | Description |
|---|---|
| Alert | Display a modal message with an OK button. |
| Bookmark | Legacy bookmark/favorite techniques and their modern limitations. |
| location | Redirect or navigate the browser to another URL. |
| Confirm | Ask the user to choose OK or Cancel and receive a Boolean result. |
| Close window | Close a script-opened browsing context where the browser allows it. |
| Open child | Open a child window and work with its reference. |
| Onload() | Run code when the window load event fires. |
| Prompt | Request a short text value from the user. |
| setInterval() | Call a function repeatedly at an interval. |
| clearInterval() | Stop a repeating interval. |
| moveBy() | Legacy/restricted movement of a script-created window relative to its current position. |
| moveTo() | Legacy/restricted movement of a script-created window to a screen position. |
| resizeTo() | Legacy/restricted resizing of a script-created window. |
| blur() | Legacy window focus behavior and modern limitations. |
| focus() | Request focus for a window where the browser permits it. |
| closed() | Check whether a referenced child window has been closed. |
| favorite | Adding a page to favorites/bookmarks: historical browser techniques. |
| Status Msg | Historical status-bar messages and current browser behavior. |
| Application | Description |
|---|---|
| Stopwatch | Incremental stopwatch controlled by buttons. |
| Refreshing | Reload a parent window after work in a child window. |
| child parent | Pass user-entered data from a child window to its parent. |
| pop up | Open and configure a popup window. |
| confirmation | Ask for confirmation before deleting a record. |
| Screen | Read screen width, height, color depth and pixel depth. |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.