tags:

views:

93

answers:

2

I m using Window.open() function to open popup, i m just passing url with querystring name Id,

i have to check wheather popup is open/closed for particular ID that is passed as querystring. If not open or closed then i will open it otherwise no need to open.

ex- first i open popup with below statement, wondow.open('Home.aspx?id=1');

then after 5 second, I want to open two pop up with Id=1 and id=2, at this time i need to check if home.aspx with id=1 is already open then no need to open one more pop up with id=1, just open for ID=2 as no popup is open for id=2

but need to ensure that two popup should not open for same querystring.

Tell me the solution

A: 

Two ways you can approach this: 1) With names for windows: Ie, depending on the id, you will have a unique name. Eg, for id=1, you would give

 window.open("Home.aspx?id=1", "MY_NAME_1");

After 5s, you would run

 window.open("Home.aspx?id=1", "MY_NAME_1");
 window.open("Home.aspx?id=2", "MY_NAME_2");

Here, it would now open a new window for id=1 if its already open, but refresh the contents inside it.

2) By taking handles like so:

var wins[];
wins[1] = window.open("Home.aspx?id=1");

and after 5 seconds,

if(wins[1] && wins[1].closed)
    window.open("Home.aspx?id=1");

Actually you can use the after 5 seconds code first time itself. I would prefer the second method.

Raze
A: 

Hi, Raze

Thanks for your response. using below code suggested byyou, window.open("Home.aspx?id=1", "MY_NAME_1"); window.open("Home.aspx?id=2", "MY_NAME_2");

it is not open new pop up but it refresh the popup. i don't want to refresh the popup. If u have any idea, please share with us.

Thanks Ripal

Ripal