As @Sudhir and @Richard showed, you can solve this problem by deferring the load of iframe
contents and it just takes a few javascript lines.
Sometimes, though, is more convenient to place the iframe
element into the source code instead of creating the element at runtime. Well, you can have it too, by initially creating the iframe
element pointing to about:blank
and changing its source at runtime:
<html>
<head>
<script>
function loadDeferredIframe() {
// this function will load the Google homepage into the iframe
var iframe = document.getElementById("my-deferred-iframe");
iframe.src = "./" // here goes your url
};
window.onload = loadDeferredIframe;
</script>
</head>
<body>
<p>some content</p>
<!-- the following iframe will be rendered with no content -->
<iframe id="my-deferred-iframe" src="about:blank" />
<p>some content</p>
</body>
</html>
Edited for @PhilHowell: I hope the idea is clearer now.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…