JavaScript Window Object

On this page

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.

Window methods and related tutorials Top ↑

Method / topicDescription
AlertDisplay a modal message with an OK button.
BookmarkLegacy bookmark/favorite techniques and their modern limitations.
locationRedirect or navigate the browser to another URL.
ConfirmAsk the user to choose OK or Cancel and receive a Boolean result.
Close windowClose a script-opened browsing context where the browser allows it.
Open childOpen a child window and work with its reference.
Onload()Run code when the window load event fires.
PromptRequest 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.
favoriteAdding a page to favorites/bookmarks: historical browser techniques.
Status MsgHistorical status-bar messages and current browser behavior.

Applications using window and related objects Top ↑

ApplicationDescription
StopwatchIncremental stopwatch controlled by buttons.
RefreshingReload a parent window after work in a child window.
child parentPass user-entered data from a child window to its parent.
pop upOpen and configure a popup window.
confirmationAsk for confirmation before deleting a record.

Screen object Top ↑

ScreenRead screen width, height, color depth and pixel depth.

JavaScript




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer