I am opening a new tab link with an element.
var w = window.open(mailto:example@gmail.com ..., '_blank');
After that I check for when it finishes loading:
if (w != null) {
console.log("here");
$(w).on('load',function () {
console.log("here2");
}
}
However, I never get "here2" printed, even long after the tab finished loading.
Notes:
I have also tried opening youtube, still here2 wasn't printed.
I tried opening the localhost link (I am runnning this on a localhost test server), and it can detect when my same site finished loading.
Can anyone help?
You can refer to this answer if the site you want to open is on the same domain as your website.
On the other side, there is nearly no hope if there is a site that does not have the same-origin content, since you will get the same-origin error.
If you have permission to add code to a "no same-origin" site (B) then you can send a signal to your original site (A) in some way (e.g. send a signal from B to the server and then send the signal return to A).