Internet Explorer 8 IFRAME onload method to analyze the failure of the Internet Explorer onload event

Source: Internet
Author: User

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);

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.