diff --git a/scripts/iframe-defer.js b/scripts/iframe-defer.js index c73c73bb..8bd59800 100644 --- a/scripts/iframe-defer.js +++ b/scripts/iframe-defer.js @@ -1,5 +1,12 @@ -setInterval(function () { - //in some cases ,the website in iframe will load result after document has been loaded. the height will continue to change. +var start_time=new Date().getTime(); + +var interval = setInterval(function () { + var end_time=new Date().getTime(); + //for 10 seconds. + if(end_time-start_time>=10000){ + clearInterval(interval); + } + const body = document.body; const html = document.documentElement; @@ -10,4 +17,4 @@ setInterval(function () { console.log("iframe set height to " + height); parentIFrame.size(height); } -}, 500); \ No newline at end of file +}, 500);