javascript - get elements that did not load -


how find out elements did not load because resource wasnt found?

    <body>        <img src="notthere.png">        <script src="notinhere.png"></script>        <img src="doesexist.png">         // want find first , script unexisting sources, not second image existing source.      </body> 

can give me hint how find out elements? think, setting onerror each element no solution because elements may loaded dynamically..

unfortunately, window.onerror not fired on 'resource not found' errors.

example:

    <body>         <script src="someonesscript.js"></script> <!-- script might load images/audio etc.. -->         <script>            // put here whatever            // find out resources (images,scripts,..) tried load (from script above)            // , can't loaded           </script>     </body> 

hope example understand question.

while theoretically possible error event , bubbling (the error event should bubble), sadly browser support weak (to least)

at best, loop through dom @ particular instant , src attributes, , check if point valid resources (by methods others have suggested). won't catch has been removed.

sources:

http://www.w3.org/tr/dom-level-2-events/events.html#events-eventgroupings-htmlevents

http://www.quirksmode.org/dom/events/error.html


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -