0

So OK, the following definitely works:

w=window.open(url);
w.onload=function (){};

But then, when I want to open a second new window (where the first new window is already processed by the function(){},i.e. becomes garbage to be collected) replacing the first new window, I tried the following which utterly fails:

w.location.href=url;
w.onload=function (){};

I am just wondering is there a solution to this? Since onload does have the power over a child window, it should in someway have the power over a child-window-replacement.

user2386986
  • 119
  • 5

1 Answers1

0

Yup, you can load to a specific window using the reference name.

For example, if you opened a window with:

 var w = window.open(url,"window1");

You can load a url to that same window by referencing the name - the second parameter. example:

 window.open(url,"window1");

Check it out: http://jsfiddle.net/JpXnc/1/

Andrew
  • 18,680
  • 13
  • 103
  • 118
  • Thanks a lot! I am just (still) wondering why I am still not able to use .onload starting from the second window... – user2386986 Jun 04 '14 at 05:38
  • Checdk out these two links, for that question: http://stackoverflow.com/questions/1372022/waiting-for-child-window-loading-to-complete http://stackoverflow.com/questions/1132537/how-can-i-check-to-see-if-a-child-browser-window-has-finished-loading – Andrew Jun 04 '14 at 05:40