Skip to content
Advertisement

how to detect window.open

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 window.open 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 window.open which was not initiated by user action.

Thanks Lynn

JavaScript

Advertisement

Answer

You can replace it

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

JavaScript

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

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement