Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the javascript open () method

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to use the javascript open () method". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to use the javascript open () method.

In javascript, the open () method navigates to a specific URL page or opens a new browser window with the syntax format "window.open (URL,name,features,replace)"; when the parameter URL is empty, a blank page opens.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

The open () method of window is used to navigate to a specific URL or to open a new browser window.

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

It takes four parameters: the URL to load, the window name, the property string, and a Boolean value. The following is introduced from two parts: parameter setting and return value of window.open

I. Parameter setting

Parameter 1: URL to be loaded (optional)

When this parameter is empty, open a blank web page; if not, navigate to the page referred to by URL or open a new browser window to display the page referred to by URL

Parameter 2: window name (optional)

Refers to the name of the window being opened:

1. The name consists of letters, numbers and underscores

2. Only one window with the same name can be created.

3. The name cannot contain spaces.

4. "_ blank", "_ self", "_ top" and "_ parent" are names with special meaning.

_ blank: displays the target web page in a new window

_ self: displays the target web page in the current window

_ top: displays the target page at the top of the frame page. If no frame is defined, this effect is the same as _ self

_ parent: displays the target web page in the upper frame (parent frame) of the frame. If it is not defined, this effect is the same as _ self

If this parameter specifies an existing window, the open () method no longer creates a new window, but simply returns a reference to the specified window.

Parameter 3: property string (optional)

Set the parameters of the window, separated by commas

Some or all of the options listed in the table can be specified by comma-separated name-value pairs, where name-value pairs are represented by an equal sign. Note that spaces are not allowed in the entire property string, as shown in the following example:

Window.open ("https://www.baidu.com","_blank","height=400,width=600,top=100,left=100,scrollbars=no");"

Parameter 4: Boolean (Boolean)

The Boolean indicates whether to replace the currently loaded page in the browser history

The above four parameters usually only need to pass the first parameter, and the last parameter is only used without opening a new window.

2. The return value of window.open

The window.open () method returns a reference to the new window so that we have more control over the new window. Such as:

MyWin= window.open ("https://www.baidu.com","_blank","height=400,width=600,top=100,left=100,scrollbars=no"); myWin.close (); / / call the close () function to close the newly opened web page myWin.resizeTo (500500); / / resize myWin.moveTo (300300)) / / move the location to this point. I believe you have a better understanding of "how to use the javascript open () method". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report