I want to calculate the time spend on the opened browser window from the parent window. the newly opened window is a youtube video or any other external website which we can't do any server-side coding.
function loadvideo(url , id){
var a = window.open(url);
a.onbeforeunload = function() {
a.console.log("hi");
}
}
I want to trigger an event when the window is closed. I tried this. it won't trigger when closing a loaded site.