javascript - Why does Firefox not display the image placeholder that failed to load?
阿神2017-05-19 10:33:43
0
2
1133
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?
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
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
Firefox directly displays the content in alt, and does not have a default picture like IE/Chrome