Home  >  Article  >  Web Front-end  >  What are the javascript window methods?

What are the javascript window methods?

青灯夜游
青灯夜游Original
2021-04-12 11:44:475184browse

The methods of the window object in JavaScript include: alert(), atob(), btoa(), blur(), close(), focus(), open(), print(), setInterval(), setTimeout(), stop(), etc.

What are the javascript window methods?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Window Object

The Window object represents the window open in the browser.

All browsers support the window object. It represents the browser window.

All global JavaScript objects, functions and variables automatically become members of the window object.

Global variables are properties of the window object.

Global functions are methods of the window object.

Even the document object (of HTML DOM) is also a window object attribute:

window.document.getElementById("header");

Equivalent to:

document.getElementById("header");

method of window object

Method Description
alert() Displays a message with a confirmation button Warning box.
atob() Decode a base-64 encoded string.
btoa() Creates a base-64 encoded string.
blur() Removes the keyboard focus from the top-level window.
clearInterval() Cancel the timeout set by setInterval().
clearTimeout() Cancel the timeout set by the setTimeout() method.
close() Close the browser window.
confirm() Displays a dialog box with a message and confirm and cancel buttons.
createPopup() Create a pop-up window.
focus() Give keyboard focus to a window.
getSelection() Returns a Selection object representing the text range selected by the user or the current position of the cursor.
getComputedStyle() Get the CSS style of the specified element.
matchMedia() This method is used to check the media query statement, which returns a MediaQueryList object.
moveBy() can move the window by the specified pixels relative to its current coordinates.
moveTo() Move the upper left corner of the window to a specified coordinate.
open() Open a new browser window or find a named window.
print() Print the contents of the current window.
prompt() Displays a dialog box that prompts the user for input.
resizeBy() Resize the window according to the specified pixels.
resizeTo() Resize the window to the specified width and height.
scroll() is obsolete. This method has been replaced by the scrollTo() method.
scrollBy() Scroll the content according to the specified pixel value.
scrollTo() Scroll the content to the specified coordinates.
setInterval() Call a function or calculate an expression according to the specified period (in milliseconds).
setTimeout() Calls a function or calculated expression after the specified number of milliseconds.
stop() Stop page loading.
postMessage() Securely implement cross-origin communication.

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of What are the javascript window methods?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn