Skip to content

how to detect

I am trying to solve a scenario and let me try to explain using an example. I have a script which tries to open a new url using method. This script triggers a window open after 5 sec without any click event from the user. What I would like to do is .. capture the window open method. Is there any function available like addEventListener to capture window open method? I would like to track a which was not initiated by user action.

Thanks Lynn

}, 5000); 


You can replace it

NOTE: does not work at stackoverflow due to sandboxing Also a not triggered by a user action will likely be suppressed by the browser

const saveOpen =; = function(url,windowName,parms) {
  saveOpen(url, windowName || "",parms || "")
const url = "", windowName="myWin"
}, 1000); 

As mentioned in How to call a function of another window in javascript? you could attach a load event listener to the window:

const loaded = function(str) { console.log(str) },
url = "", windowName="myWin";
  const w =,windowName);
  if (w) w.addEventListener('load',function() { loaded(url)})
  else console.log('sorry, not allowed'); // this of course can be a call to whatever
}, 1000);