@arnoldo.moen
There are several ways to check whether an iframe has loaded content:
1 2 3 4 5 6 7 8 9 |
var iframe = document.getElementById('myIframe');
iframe.addEventListener('load', function() {
if (iframe.contentDocument && iframe.contentDocument.body) {
console.log('iframe loaded content');
} else {
console.log('iframe did not load content');
}
});
|
1 2 3 4 5 6 7 8 |
<iframe id="myIframe" src="https://example.com"></iframe>
<script>
var iframe = document.getElementById('myIframe');
iframe.onload = function() {
console.log('iframe loaded content');
};
</script>
|
1 2 3 4 5 6 7 |
var iframe = document.getElementById('myIframe');
if (iframe.complete) {
console.log('iframe loaded content');
} else {
console.log('iframe did not load content');
}
|
By using one of these methods, you can check whether an iframe has loaded content.