About how to use the properties and methods of window in JS

不言
Release: 2018-07-16 17:25:07
Original
2245 people have browsed it

This article mainly introduces the analysis of window attributes and methods in JS. It has certain reference value. Now I share it with everyone. Friends in need can refer to it.

Objects can be written without using window This prefix

setInterval() – executes the specified code continuously for the specified number of milliseconds.

clearInterval() – Function code used to stop the execution of the setInterval() method.

setTimeout() - Execute the specified code after pausing for the specified number of milliseconds

clearTimeout() - Function code used to stop executing the setTimeout() method

Example:

Use a timer to display the clock on the page
•The time format is: xxxx year xx month xx day xx:xx:xx to seconds
•Refresh once per second

1  2  3  4  5 
Copy after login
Copy after login

close( ) - Close the current window

open() - Open a new window and return the object of the new window

Syntax window.open(URL,name,features,replace);

URL: Optional string that declares the URL of the new window. If this parameter is omitted or the value is an empty string, the new window will not display any documents

name: optional string, which is a comma-separated list of features that declares the name of the new window. If this parameter specifies a window that already exists, the open method returns a reference to the specified window (no new window is created). At this time, features will be ignored.

features: Optional string that declares the standard browser features displayed in the new window. If omitted, the new window has all standard features.

replace: an optional boolean value. Specifies whether a URL loaded into a window creates a new entry in the window's browsing history, or replaces the current entry in the browsing history. The following values are supported:•true - The URL replaces the current entry in the browsing history. •false - The URL creates a new entry in the browsing history.

The third parameter of the open() method is as follows

Whether the window is resizable. The default is yes. Whether to display scroll bars. The default is yes. Whether to add a status bar. The default is yes. Whether to display the title bar. The default is yes. Whether to display the browser toolbar. The default is yes. The y coordinate of the window. The width of the document display area of the window. Measured in pixels.
##channelmode=yes|no|1|0

Whether to use theater mode to display the window. Default is no.

resizable=yes|no|1|0

directories=yes|no|1|0

Whether to add a directory button. Default is yes.

scrollbars=yes|no|1|0

fullscreen=yes|no|1|0

Whether to display the browser in full screen mode. The default is no.

A window in full screen mode must also be in theater mode.

status=yes|no|1|0

height=pixels

The height of the window document display area. Measured in pixels.

titlebar=yes|no|1|0

left=pixels

The x-coordinate of the window. Measured in pixels.

toolbar=yes|no|1|0

location=yes|no|1|0

Whether to display the address field. The default is yes.

top=pixels

menubar=yes|no|1|0

Whether to display the menu bar. The default is yes.

width=pixels

Location object properties

hash

Settings Or returns a URL starting with a pound sign (#) (anchor).

host

Set or return the host name and port number of the current URL.

hostname

Sets or returns the hostname of the current URL.

href

Sets or returns the full URL.

pathname

Sets or returns the path portion of the current URL.

port

Set or return the port number of the current URL.

protocol

Set or return the protocol of the current URL.

search

Sets or returns the URL (query part) starting with a question mark (?).

The following is an example

Copy after login
Location object method

assign() Load a new document.

reload() Reload the current document, which is equivalent to refreshing the page.

replace() Replace the current document with a new document.

(location.replace("location.html#top?a=10&b=20"); is equivalent to location.href = "location.html#top?a=10&b=20";)

Related recommendations:

How to transfer functions in js

Parsing of custom objects in js

The above is the detailed content of About how to use the properties and methods of window in JS. 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!