window.open, open the window and open a new tab, refresh the parent window data

window.open(url, [name], [configuration])

url, 为要新打开页面的url
name,为新打开窗口的名字,可以通过此名字获取该窗口对象
configuration,为新打开窗口的一些配置项,比如是否有菜单栏、滚动条、长高等等信息

1. name is the name of the open window, which can be customized. If the name is the same, only one window will be opened multiple times;

      It can also be the following value. If it is the following value, multiple windows will be opened regardless of whether the page is the same.

name describe
_blank By default, the URL of the link will be opened in a new window.
_self Open link url in current window
_parent Open the link url in the parent window
_top Open url in top-level window
framename Open the link url in the specified frame

2. window.open(url, name) Generally, browsers open a new tab. If you want to open a new window, you need to add the conifguration parameter , for example:

window.open('https://www.baidu.com/', item.className, 'width=800,height=600,top=100,left=200,toolbar=yes,scrollbars=yes')
parameter value illustrate
top number Number of pixels from the top of the window to the top of the screen
left number Number of pixels from the left side of the window to the left side of the screen
width number window width
height number window height
menubar yes/no Does the window have a menu?
toolbar yes/no Does the window have toolbars?
scrollbars yes/no Does the window have scroll bars?
status yes/no Does the window have a status bar?

 3. Scenario: Open a new window b on page a. After the new window submits data, close the window. At the same time, the list data of page a needs to be refreshed. At this time, you can use the window.opener.location.reload() method to execute the created Main window operations.

4. Correspondingly, for more window methods, window.parent, please refer to the Window object | Rookie Tutorial

5. Postmessage method, use localstorge to store data and then use window.addEventListener("storage", function (e) { console.log(e) console.log(e.newValue) })

Guess you like

Origin blog.csdn.net/ringlot/article/details/120220971