5

I would like to know if I can get a list of popups opened by window.open javascript function call.

I want to run some code after all these pages are closed. I don't mind if the solution was plain javascript or JQuery.

Thanks in advance.

thelinuxer
  • 658
  • 1
  • 8
  • 28

2 Answers2

5

No, you can't get a list of windows opened by the page via window.open (sadly). You'll have to keep track of them as you open them (assuming it's you who opens them).

If you were to do the more modern style of popup instead (positioned elements opened as virtual windows within the page), then of course you could readily get a list of them by doing a simple selector query (just add a class to them when they're showing, and then query the DOM for elements with that class).

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • 1
    I just wanna add this answer because this is an alternative solution http://stackoverflow.com/questions/6340160/how-to-get-the-references-of-all-already-opened-child-windows – Skatox Jan 26 '15 at 19:48
-2

you can use localstorage to do this. I am also using a localstorage plugin so the set and get are short hand.

function Op(r,rr,rrr){
    if(!rrr){rrr={};};if(!rrr.n){rrr.n='PopUps'}
    ii={o:jQuery.localStorage.get(rrr.n)}
    if(!ii.o){
        switch(rrr.n){
            case'unmOptions':
                ii.o={audio0:1,audio1:1}
            break;
            default:
                ii.o={p:{}}
            break;
        }
    }
    if(r&&rr&&!rrr.x){
        ii.o[r]=rr;
    }
    switch(rrr.x){
        case 0:
            delete(ii.o[r])
        break;
        case 1:
            delete(ii.o[r][rr])
        break;
    }
    jQuery.localStorage.set(rrr.n,ii.o)
    return ii.o
}

How to get object of windows

Op()
Op().p['window1']

to set values

Op('key','value')

to delete values

Op('key','',{x:0})
moeiscool
  • 1,318
  • 11
  • 14