0

In my view source page below lines are in red color.

<img alt="4054775 1991 Chevrolet Camaro" class="image" onerror="this.onerror=null;this.src='/images/nophoto_250.gif'"; 
src="http://carphotos3.cardomain.com/images/0016/35/82/16355328_large.jpg"   />

I think

onerror="this.onerror=null;this.src='/images/nophoto_250.gif'";

is incorrect. Or else why these lines are in red color??

Thanks

  • That (`onerror`) isn't a valid attribute of an `img` tag, but that appears to be how they prevent broken images link from loading in their page. – Elliott Frisch Jun 25 '14 at 07:08
  • so is it compulsory to remove that onerror from img tag?? – user3725640 Jun 25 '14 at 07:11
  • Compulsory? No. Violations are met with a stern talking to by the secrete committee on... Perhaps I've said too much. – Elliott Frisch Jun 25 '14 at 07:14
  • or can i use something else to prevent broken img?? it is difficult to remove **onerror** in all pages in my website. – user3725640 Jun 25 '14 at 07:14
  • @user3725640 No.it is not compulsory to remove that onerror from img..check my answer – Mr7-itsurdeveloper Jun 25 '14 at 07:14
  • Duplicate: http://stackoverflow.com/questions/3984287/how-to-show-alternate-image-if-source-image-is-not-found-onerror-working-in-ie and http://stackoverflow.com/questions/717734/best-way-to-display-default-image-if-specified-image-file-is-not-found eso! – Nicolas Henrard Jun 25 '14 at 07:15

1 Answers1

0

First of all remove semi-colon after onerror

use html doctype proper

<!DOCTYPE html>
<html>
<head>

</head>
<body> 
<p>If you click on me, I will disappear.</p> 
<p>Click me away!</p>
<p>Click me too!</p>
<img alt="4054775 1991 Chevrolet Camaro" class="image" onerror="this.onerror=null;this.src='/images/nophoto_250.gif'"
src="http://carphotos3.cardomain.com/images/0016/35/82/16355328_large.jpg"   /> 
</body>
</html>
Mr7-itsurdeveloper
  • 1,631
  • 2
  • 17
  • 24