user2684308
user2684308

Reputation: 53

referencing windows in Javascript

Is there a way to reference a popup window in Javascript or JQuery that identifies each window with a unique name? I declare one variable to create the window but in the event of multiple popup windows, I was wondering if the 'name' attribute could somehow be attached to a Jquery selector to target a specific window?

 var popup = open('message.html',"'" + name + "'", 'height=300,width=300,location=no,resizable=yes,scrollbars=yes');

Upvotes: 2

Views: 51

Answers (1)

Felix Kling
Felix Kling

Reputation: 816810

You can use an object as map:

var popups = {};
// ...
popups[name] = open('message.html', name, ...);
// ...
popups[name].close();

Learn more about objects.

Upvotes: 5

Related Questions