Saturday, November 13, 2010

Javascript - Checking Image Existence

At first I wondered is there any way to validate a  image url in javascript. Later i found that the img tag has some events those are really helpful in doing that.
I hope it might help somebody.

<img border="0" 
onerror="alert('failed')" onsuccess="alert('success')" 
src="https://www.google.com/images/logos/ssl_logo_lg.gif" />

Really Simple.Huh?

No comments:

Post a Comment