¡@

Home 

2014/10/16 ¤W¤È 12:04:29

jquery Programming Glossary: istype

Detecting a image 404 in javascript

http://stackoverflow.com/questions/3019077/detecting-a-image-404-in-javascript

id id.nodeType 1 id document.getElementById id function isType o t return typeof o .indexOf t.charAt 0 .toLowerCase 0 Here's.. function image src cfg var img prop target cfg cfg isType src 'o' src img src if img src cfg.src img.src else img document.createElement.. 'img' src src cfg.src if src return null prop isType img.naturalWidth 'u' 'width' 'naturalWidth' img.alt cfg.alt..

Detecting a image 404 in javascript

http://stackoverflow.com/questions/3019077/detecting-a-image-404-in-javascript

loaded.html First a couple helper functions function id return id id.nodeType 1 id document.getElementById id function isType o t return typeof o .indexOf t.charAt 0 .toLowerCase 0 Here's the meat and potatoes function image src cfg var img prop.. o .indexOf t.charAt 0 .toLowerCase 0 Here's the meat and potatoes function image src cfg var img prop target cfg cfg isType src 'o' src img src if img src cfg.src img.src else img document.createElement 'img' src src cfg.src if src return null.. src img src if img src cfg.src img.src else img document.createElement 'img' src src cfg.src if src return null prop isType img.naturalWidth 'u' 'width' 'naturalWidth' img.alt cfg.alt img.alt Add the image and insert if requested must be on DOM..