Reputation: 1
I want an event to fire after iframe's source page is loaded into DOM to do some customization client side. Please help me.
Upvotes: 0
Views: 46
Reputation: 1075795
If the iframe's content is from the same origin as the containing page, you can listen for the DOMContentLoaded
event on it:
theFrame.documentWindow.addEventListener("DOMContentLoaded", function() {
// ...
});
(If the content isn't from the same origin, I don't think you can hook that event — but that doesn't matter, because you wouldn't be able to do the customization you've mentioned, either. :-) )
Upvotes: 2
Reputation: 18639
Use onload
event:
document.getElementById("iframe-id").addEventListener("load",event=>{
//Do some stuff when iframe loaded
})
Upvotes: 1