Window

Обновлено: 09.03.2023

Об'єкт Window

Об'єкт window представляє відкрите вікно в браузері.

Якщо документ містить фрейми (теги <iframe>), браузер створює один об’єкт вікна для документа HTML і один додатковий об’єкт вікна для кожного фрейму.

Властивості та методи об’єкта «Window»

  • closed

    closed

    Returns a boolean true if a window is closed.

  • console

    console

    Returns the Console Object for the window. See also The Console Object.

  • defaultStatus

    defaultStatus

    Deprecated.

  • document

    document

    Returns the Document object for the window. See also The Document Object.

  • frameElement

    frameElement

    Returns the frame in which the window runs.

  • frames

    frames

    Returns all window objects running in the window.

  • history

    history

    Returns the History object for the window. See also The History Object.

  • innerHeight

    innerHeight

    Returns the height of the window's content area (viewport) including scrollbars

  • innerWidth

    innerWidth

    Returns the width of a window's content area (viewport) including scrollbars

  • length

    length

    Returns the number of <iframe> elements in the current window

  • localStorage

    localStorage

    Allows to save key/value pairs in a web browser. Stores the data with no expiration date

  • location

    location

    Returns the Location object for the window. See also the The Location Object.

  • name

    name

    Sets or returns the name of a window

  • navigator

    navigator

    Returns the Navigator object for the window. See also The Navigator object.

  • opener

    opener

    Returns a reference to the window that created the window

  • outerHeight

    outerHeight

    Returns the height of the browser window, including toolbars/scrollbars

  • outerWidth

    outerWidth

    Returns the width of the browser window, including toolbars/scrollbars

  • pageYOffset

    pageYOffset

    Returns the pixels the current document has been scrolled (vertically) from the upper left corner of the window

  • parent

    parent

    Returns the parent window of the current window

  • screen

    screen

    Returns the Screen object for the window See also The Screen object

  • screenLeft

    screenLeft

    Returns the horizontal coordinate of the window relative to the screen

  • screenTop

    screenTop

    Returns the vertical coordinate of the window relative to the screen

  • screenX

    screenX

    Returns the horizontal coordinate of the window relative to the screen

  • screenY

    screenY

    Returns the vertical coordinate of the window relative to the screen

  • sessionStorage

    sessionStorage

    Allows to save key/value pairs in a web browser. Stores the data for one session

  • scrollX

    scrollX

    An alias of pageXOffset

  • scrollY

    scrollY

    An alias of pageYOffset

  • self

    self

    Returns the current window

  • status

    status

    Deprecated. Avoid using it.

  • top

    top

    Returns the topmost browser window

  • addEventListener()

    addEventListener()

    Attaches an event handler to the window

  • alert()

    alert()

    Displays an alert box with a message and an OK button

  • atob()

    atob()

    Decodes a base-64 encoded string

  • blur()

    blur()

    Removes focus from the current window

  • btoa()

    btoa()

    Encodes a string in base-64

  • clearInterval()

    clearInterval()

    Clears a timer set with setInterval()

  • clearTimeout()

    clearTimeout()

    Clears a timer set with setTimeout()

  • close()

    close()

    Closes the current window

  • confirm()

    confirm()

    Displays a dialog box with a message and an OK and a Cancel button

  • focus()

    focus()

    Sets focus to the current window

  • getComputedStyle()

    getComputedStyle()

    Gets the current computed CSS styles applied to an element

  • scroll()

    scroll()

    Deprecated. This method has been replaced by the scrollTo() method.

  • matchMedia()

    matchMedia()

    Returns a MediaQueryList object representing the specified CSS media query string

  • moveBy()

    moveBy()

    Moves a window relative to its current position

  • moveTo()

    moveTo()

    Moves a window to the specified position

  • open()

    open()

    Opens a new browser window

  • print()

    print()

    Prints the content of the current window

  • prompt()

    prompt()

    Displays a dialog box that prompts the visitor for input

  • removeEventListener()

    removeEventListener()

    Removes an event handler from the window

  • resizeBy()

    resizeBy()

    Resizes the window by the specified pixels

  • resizeTo()

    resizeTo()

    Resizes the window to the specified width and height

  • scrollBy()

    scrollBy()

    Scrolls the document by the specified number of pixels

  • scrollTo()

    scrollTo()

    Scrolls the document to the specified coordinates

  • setInterval()

    setInterval()

    Calls a function or evaluates an expression at specified intervals (in milliseconds)

  • setTimeout()

    setTimeout()

    Calls a function or evaluates an expression after a specified number of milliseconds

  • stop()

    stop()

    Stops the window from loading


PropertyDescription
closedReturns a boolean true if a window is closed.
consoleReturns the Console Object for the window.
See also The Console Object.
defaultStatusDeprecated.
documentReturns the Document object for the window.
See also The Document Object.
frameElementReturns the frame in which the window runs.
framesReturns all window objects running in the window.
historyReturns the History object for the window.
See also The History Object.
innerHeightReturns the height of the window's content area (viewport) including scrollbars
innerWidthReturns the width of a window's content area (viewport) including scrollbars
lengthReturns the number of <iframe> elements in the current window
localStorageAllows to save key/value pairs in a web browser. Stores the data with no expiration date
locationReturns the Location object for the window.
See also the The Location Object.
nameSets or returns the name of a window
navigatorReturns the Navigator object for the window.
See also The Navigator object.
openerReturns a reference to the window that created the window
outerHeightReturns the height of the browser window, including toolbars/scrollbars
outerWidthReturns the width of the browser window, including toolbars/scrollbars
pageXOffsetReturns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window
pageYOffsetReturns the pixels the current document has been scrolled (vertically) from the upper left corner of the window
parentReturns the parent window of the current window
screenReturns the Screen object for the window
See also The Screen object
screenLeftReturns the horizontal coordinate of the window relative to the screen
screenTopReturns the vertical coordinate of the window relative to the screen
screenXReturns the horizontal coordinate of the window relative to the screen
screenYReturns the vertical coordinate of the window relative to the screen
sessionStorageAllows to save key/value pairs in a web browser. Stores the data for one session
scrollXAn alias of pageXOffset
scrollYAn alias of pageYOffset
selfReturns the current window
statusDeprecated. Avoid using it.
topReturns the topmost browser window
MethodDescription
addEventListener()
Attaches an event handler to the window
alert()
Displays an alert box with a message and an OK button
atob()
Decodes a base-64 encoded string
blur()
Removes focus from the current window
btoa()
Encodes a string in base-64
clearInterval()
Clears a timer set with setInterval()
clearTimeout()
Clears a timer set with setTimeout()
close()
Closes the current window
confirm()
Displays a dialog box with a message and an OK and a Cancel button
focus()
Sets focus to the current window
getComputedStyle()
Gets the current computed CSS styles applied to an element
getSelection()
Returns a Selection object representing the range of text selected by the user
matchMedia()
Returns a MediaQueryList object representing the specified CSS media query string
moveBy()
Moves a window relative to its current position
moveTo()
Moves a window to the specified position
open()
Opens a new browser window
print()
Prints the content of the current window
prompt()
Displays a dialog box that prompts the visitor for input
removeEventListener()
Removes an event handler from the window
requestAnimationFrame()
Requests the browser to call a function to update an animation before the next repaint
resizeBy()
Resizes the window by the specified pixels
resizeTo()
Resizes the window to the specified width and height
scroll()
Deprecated. This method has been replaced by the scrollTo() method.
scrollBy()
Scrolls the document by the specified number of pixels
scrollTo()
Scrolls the document to the specified coordinates
setInterval()
Calls a function or evaluates an expression at specified intervals (in milliseconds)
setTimeout()
Calls a function or evaluates an expression after a specified number of milliseconds
stop()
Stops the window from loading