Home >Web Front-end >JS Tutorial >What is the use of the javascript open() method?
In JavaScript, the function of the open() method is to navigate to a specific URL web page or open a new browser window, the syntax format is "window.open(URL,name,features,replace)"; When the parameter URL is empty, a blank web page will be opened.
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.
window’s open() method is used to navigate to a specific URL or open a new browser window.
Syntax: window.open(URL,name,features,replace)
It receives 4 parameters: the URL to load, the window name, the attribute string and a Boolean value . The following will introduce the parameter settings and return values of window.open.
Parameters Number one: URL to be loaded (optional)
When this parameter is empty, open a blank web page; if it is not empty, navigate to the URL pointed to The web page or open a new browser window to display the web page pointed to by the URL
Parameter 2: Window name (optional)
refers to the name of the opened window:
##
# 2. Only one window with the same name can be created
Contains spaces
4. “_blank”, “_self
”, “_top
”, “_parent
” is a name with special meaning
#: Display the target web page in a new window; <span style="font-size:18px"><span style="font-size:14px">## </span></span>
: The target webpage is displayed on the upper part of the frame webpage. If there is no definition framework, this effect is the same as _Self ##
If this parameter specifies an existing window, the open() method will no longer create a new window, but will just return the specified window. Quote.
Parameter three: Characteristic string (optional)
Set the parameters of the window, each Parameters are separated by commas
# # The part or all options listed in Tables can be specified by the name value of the comma separation. No spaces are allowed, as shown in the following example: Parameter four: Boolean value (Boolean value) This Boolean indicates: whether to replace the currently loaded page in the browser history The above four parameters usually only need Pass the first argument, the last argument is only used without opening a new window. The window.open() method returns a reference to the new window so that we can Windows for more control. Such as:
[Recommended learning: javascript advanced tutorial] window.open("https://www.baidu.com","_blank","height=400,width=600,top=100,left=100,scrollbars=no");
2. The return value of window.open
myWin= window.open("https://www.baidu.com","_blank","height=400,width=600,top=100,left=100,scrollbars=no");
myWin.close(); //调用close()函数关闭新打开的网页
myWin.resizeTo(500,500); //调整大小
myWin.moveTo(300,300); //移动位置
The above is the detailed content of What is the use of the javascript open() method?. For more information, please follow other related articles on the PHP Chinese website!