Perfect Method for judging whether IFRAME is loaded
IE supports IFRAME onload events, but they are invisible and need to be registered through attachevent.
The second method is more perfect than the first method (using readystatechange), because the readystatechange event has some potential problems compared with the load event.
I feel that this is not completely accurate, and it has caused me a lot of trouble. I can see from its code that in the real sense, the onload method of IE when creating a new IFRAME needs to be bound using attachevent, and the existing onload method of IFRAME, you can bind it directly.
Here, we also refer to the "perfect method for judging whether IFRAME is loaded" mentioned in the original article"
1 var iframe = document_createElement_x_x("iframe"); 2 3 iframe.src = "http://www.020cityshop.com"; 4 5 if (iframe.attachEvent){ 6 7 iframe.attachEvent("onload", function(){ 8 9 alert("Local iframe is now loaded.");10 11 });12 13 } else {14 15 iframe.onload = function(){16 17 alert("Local iframe is now loaded.");18 19 };20 21 }22 23 document.body.a(iframe);