It is possible to detect when <iframe>
leaves a page, provided you have access to that page:
IFRAME.contentWindow.addEventListener("unload", function() {
parent.console.log("Unloading.");
});
But this requires that
- You have access to the inner page (I have, but still...)
- There is some inner window
You wait for the frame to load to assign this event, so the actual code is:
fr.onload = function() { this.contentWindow.addEventListener("unload", function() { parent.console.log("Unload."); }); console.log("Load"); }
... and the onload event takes very very very long on modern pages (due to stupid facebook like plugins and similar stuff).
I am making an userscript and the requirement is that I am detect when, within the <iframe>
document starts being loaded, the moment when javascript is already working in that document. If this is not possible, then at least the event when the webpage has been loaded and is only waiting for asynchronous data (CSS, images, IFRAMEs).