To detect whether an iframe is loaded with JavaScript, we set the onload
property of the iframe to a function that’s called when the iframe is loaded.
For instance, we write
<iframe style="display: none" id="MainPopupIframe" src=""></iframe>
to add the iframe.
Then we write
const ifr = document.getElementById("MainPopupIframe");
ifr.onload = () => {
console.log("loaded the iframe");
};
to select the iframe with getElementById
.
And then we set its onload
property to a function that’s called when the iframe is loaded.