How to replace broken images using JavaScript in HTML?

How can we replace the 404 images with a default image using JavaScript by the time page loads?

Comments

  • <img src="your-image.png" onError="this.onerror=null;this.src='/path/noimage.gif';" />

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion