Maintain reference to popup window over page refresh in Javascript

Does anyone know if there is a way to maintain the reference to a popup window after you refresh the page so you can keep on accessing it?

My initial thought was to stringify the reference variable with JSON, store it in a cookie and eval() it after the page was refreshed, but I haven't had a chance to test it out yet.

Am I on the right track, or is this even possible?

Answers:

Answer

Inside your child window try something like this:

window.setInterval(function(){
 try{
  window.opener.win = window;
 } catch(e){}
}, 300);

I got this from here. It seems to work on all browsers.

Answer

Hmm since http / page requests are stateless I don't think that there's any way to keep the reference. I'm not sure what you want to do with the popup, but maybe you can use an iframe or fake the refresh with an Ajax request?

Interesting for sure!

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.