find out popup is open/closed for particular url with querystring
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开发者_JAVA百科 is open for id=2
but need to ensure that two popup should not open for same querystring.
Update:
Using the code below suggested by Raze,
window.open("Home.aspx?id=1", "MY_NAME_1");
window.open("Home.aspx?id=2", "MY_NAME_2");
it is not opening a new popup but it refreshes the old popup. I don't want to refresh the popup. If you have any idea, please share with us.
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.
精彩评论