通过javascript判断图片是否存在,不存在则显示另一图片
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>demo</title>
- <script type="text/javascript">
- var thisSiteURL = 'http://paopao8.com/';
- var thisTopicLength = '140';
- var thisMod = 'topic';
- var thisCode = '';
- var isQunClosed = false;
- function faceError(imgObj)
- {
- var errorSrc='http://www.paopao8.com/static/images/logo.gif';
- imgObj.src = errorSrc;
- }
- </script>
- </head>
- <body>
- <img src="credit_info_s1.png" onerror="javascript:faceError(this);" width="178" height="178" />
- <img src="credit_info_s2.png" onerror="javascript:faceError(this);" width="178" height="178" />
- </body>
- </html>
本文转自 ppabc 51CTO博客,原文链接:http://blog.51cto.com/ppabc/744797