<img src="image_not_found.jpg" onError="this.style.display = 'none';" alt="" />
The above code does not work in chrome, after deleting still shows image not found. But it works in firefox, what else should i add to make it work in chrome. Mine is a php website
<img src="image_not_found.jpg" onError="this.style.display = 'none';" alt="" />
The above code does not work in chrome, after deleting still shows image not found. But it works in firefox, what else should i add to make it work in chrome. Mine is a php website
Share Improve this question edited Nov 4, 2013 at 6:10 Josh Lee 178k39 gold badges277 silver badges281 bronze badges asked Nov 4, 2013 at 6:07 AparnaAparna 111 gold badge1 silver badge4 bronze badges 6-
Are you sure it works in FF? FF hides not-found images by default anyway, if they don't have
alt
attribute or it's empty. – Teemu Commented Nov 4, 2013 at 6:12 - 2 The result should be nothing, which is what I'm getting in Chrome: jsfiddle/L8xvE – Rhyono Commented Nov 4, 2013 at 6:13
- @Teemu There isn't one. – Rhyono Commented Nov 4, 2013 at 6:23
- <img class="example-image" src="../<?php echo $ongoing_gal_home[$i]['thumb']; ?>" onError="this.style.display = 'none';" alt="" /></a> still it shows image not found??? – Aparna Commented Nov 4, 2013 at 6:27
-
1
You've the
onerror
s attached toa
elements instead ofimg
elements on your page... – Teemu Commented Nov 4, 2013 at 6:55
2 Answers
Reset to default 4Try small letters:
onerror="this.style.display = 'none'"
This might be of help if you want to style 'onerror' or broken images. It really resolved an issue I battled with for a while.
<img src="/path/toimage" alt="my image" onerror="this.onerror=null;this.src='/broken-img.svg';this.classList.add('broken-img');">