异步处理img onerror

        
        var source = '<img src="not_found.jpg" onerror="alert(1)">';
        var range = document.createRange();
        range.createContextualFragment(source); // onerror が実行される

        var img = document.createElement('img');
        img.setAttribute('onerror', 'alert(2)');
        img.src = 'not_found.jpg'; // onerror が実行される
原文地址:https://www.cnblogs.com/rubylouvre/p/1715081.html