What are the javascript window methods?

青灯夜游
Release: 2023-01-04 09:36:08
Original
5091 people have browsed it

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");
Copy after login

Equivalent to:

document.getElementById("header");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!