0
votes

Having following code

<iframe id="myframe" src="..."></iframe>

<script>
document.getElementById('myframe').onload = function() {
  alert('myframe is loaded');
};
</script>

Am I right that the iframe is loaded in the separate thread and so its possible that the alert may not fire because iframe content may load before we assign onload event handler in the script running the main thread?

1

1 Answers

0
votes

You can use it this way also. iframe is loaded in the main thread / process, not a separate one. Your alert will come up once it is loaded.

<iframe id="myframe" src="..." onload="javascript:alert('myframe is loaded');"></iframe>