首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用mootools1.2用错误图像替换网页中的损坏图像

如何用mootools1.2用错误图像替换网页中的损坏图像
EN

Stack Overflow用户
提问于 2010-02-04 17:02:34
回答 1查看 473关注 0票数 1

我在php,mysql上运行,并使用mootools1.2作为我的js框架。

我希望所有损坏的图像都应该替换为一个错误图像。

我该怎么做呢?

谢谢

阿维纳什

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-04 17:07:29

这个链接可能会有帮助,http://davidwalsh.name/custom-missing-image

代码语言:javascript
复制
1 window.addEvent('domready',function() {
2  /* version 1 */
3  $$('img.missing1').addEvent('error',function() {
4    this.set({
5      src: 'http://davidwalsh.name/dw-content/missing-image.jpg',
6      alt: 'Sorry!  This image is not available!',
7      styles: {
8        width: 110,
9        height:40
10      }
11    });
12  });
13  /* version 2 */
14  $$('img.missing2').addEvent('error',function() {
15    this.set({
16      src: 'http://davidwalsh.name/dw-content/missing-image-2.jpg',
17      alt: 'Sorry!  This image is not available!',
18      styles: {
19        width: 30,
20        height:28
21      }
22    });
23  });
24 });
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2198391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档