javascript - Why does Firefox not display the image placeholder that failed to load?
阿神
阿神 2017-05-19 10:33:43
0
2
1093
404 for loading images on the

page, a placeholder for loading failure will be displayed under Chrome and IE (as shown in the picture), so that users can directly see that there are images being loaded. Failed, but why doesn't Firefox display a similar placeholder?

阿神
阿神

闭关修行中......

reply all(2)
漂亮男人

Firefox is special, you can try the following activation method
Enter about:config in the address bar to find browser.display.showimageplaceholders, and set the value to true

In addition, if the picture is not displayed, it is best not to use placeholders. You can try several methods to give the default picture when the picture fails to load.

Method 1

Lazy loading method, determine whether the real img is loaded successfully before src assignment

Method 2

Convert a small amount of img

`<img src='real.jpg' alt='test' onerror="this.src='default.jpg'">
`

Batch img conversion
  $('img').error(function(){
            $(this).attr('src', "default.jpg");
         });
左手右手慢动作

Firefox directly displays the content in alt, and does not have a default picture like IE/Chrome

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!