Reputation: 133
I need help in managing multiple named popups created via 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.
var myWindow = window.open("_url", uniqueId, "other params...")
if I create a single popup, it can be reloaded by calling 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.
I was thinking of maybe creating a global javascript map with window.open
references in it.
something like:
var myWindowArray = [];
myWindowArray[uniqueId] = window.open("_url", uniqueId, "other params...");
and later reload this popup by calling 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
Upvotes: 0
Views: 179
Reputation: 4283
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. You should always try things on your own first before asking.
Upvotes: 1