Catch javascript: window.close () inside iframe

I am running third-party HTML content inside an iframe , with which I do not control, and in some cases they have links that call javascript: window.close () directly. Something like that:

<input type="button" onclick="javascript:window.close()" value ="CLOSE">

I have no way to find the identifier or array position of this element.

Naturally, it is ignored inside the iframe, but is there a way to catch when this event is fired? I tried

window.addEventListener("close", closeHandler, false);
window.addEventListener("onbeforeunload", closeHandler, false);

but he completely ignores him. Is there a way to somehow catch ALL JavaScript events / calls? Any recommendations are appreciated.

+5
source share
1 answer

, . , . iframe, . postMessage.

0

All Articles