This is a lot of inspection, a better idea
<textarea id="runcode37611"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> Show default picture when no picture is present" practice by Ahanan </title> <style type= "Text/css" > img{ border:1px solid #cccccc; width:100px; height:50px; } </style> </pead> <body> </body> </ptml> <script type= " Text/javascript "> var imgs = document.images; for (var i = 0;i < imgs.length;i++) {imgs[i].onerror = function () {THIS.SRC = "http://www. Jb51.net/images/logo.gif "; }} </script></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Use JavaScript to determine whether a picture exists, does not exist the code that displays the default picture can refer to the following
Http://www.jb51.net/article/8796.htm