简体   繁体   English

管理多个弹出窗口

[英]Manage multiple Popups

I need help in managing multiple named popups created via window.open(). 我需要管理通过window.open()创建的多个命名弹出窗口的帮助。 There are multiple popups all with a unique ID and my application requires some popups be reloaded after an ajax success in the parent window. 有多个具有唯一ID的弹出窗口,我的应用程序要求在父窗口中执行ajax成功后重新加载一些弹出窗口。

var myWindow = window.open("_url", uniqueId, "other params...")

if I create a single popup, it can be reloaded by calling myWindow.location.reload() . 如果创建单个弹出窗口,则可以通过调用myWindow.location.reload()重新加载它。 However, I am not sure how it can be done as the reference to the current popup in myWindow object gets updated everytime a new popUp is opened. 但是,我不确定如何做,因为每次打开新的popUp时,对myWindow对象中当前弹出窗口的引用都会更新。

I was thinking of maybe creating a global javascript map with window.open references in it. 我当时正在考虑使用window.open引用创建一个全局javascript映射。 something like: 就像是:

var myWindowArray = [];
myWindowArray[uniqueId] = window.open("_url", uniqueId, "other params...");

and later reload this popup by calling myWindowArray[uniqueId].location.reload() . 然后通过调用myWindowArray[uniqueId].location.reload()重新加载此弹出窗口。

I am not sure if this will work or if there is a better method for managing such circumstances. 我不确定这是否行得通,或者是否有更好的方法来管理这种情况。

Thanks in advance 提前致谢

The following is what you are looking for 以下是您要寻找的

var dict = {};
dict["MY_FIRST_WINDOW"] = window.open("_url", "MY_FIRST_WINDOW", "other params...");
dict["MY_FIRST_WINDOW"].location.reload();

but you say I am not sure if this will work , and that is a problem. 但是您说I am not sure if this will work ,这是一个问题。 You should always try things on your own first before asking. 在询问之前,您应该始终先自行尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM