How can we know when pop-up window url is loaded (window.open)?
javascript, jquery
Solution
`window.open` returns a reference to that window's `window` object.
If the opened window is pointing to a URL on the same domain as the window opener, then it will have full access to that object just as it does it's own `window` object.
var w = window.open(url);
// If the window opened successfully (e.g: not blocked)
if ( w ) {
w.onload = function() {
// Do stuff
};
}
The same origin policy applies here. If the URL of the opened window is on a different domain, then the opener will not have access to members of that window's reference.
Problem
I need to change the URL of the page in the pop-up as soon as it completes loading ( I am using window.open function call). Is there anyway I can find out when the page in pop-up has completed loading in the parent window? I cannot change anything in the page I am opening in pop-up, because it belongs to another website.