Iframe content loading process

2019-07-23 07:21发布

问题:

Having following code

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

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

i wonder how does the browser processes an iframes? Does it load the iframe content in the separate thread? If so is it run synchronously with the main thread?

回答1:

That depends stronly to the browser. Internet Explorer for example starts a seperated thread for each tab you open, some might do that otherwise. Actually, some browsers support specially secured threads for frames: https://www.chromium.org/developers/design-documents/oop-iframes

So, which browser are you asking for especially?



回答2:

The iframe is loading sync with the main website. If you want to load the content of the main site first

<body onload="javascript:...">


标签: html iframe