dongmu6578 2010-02-04 09:02
浏览 43
已采纳

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

i am running on php, mysql and using mootools1.2 as my js framework.

I want that all broken images should replace with a single error image.

How should i do this.

Thanks

Avinash

  • 写回答

1条回答 默认 最新

  • douyao2529 2010-02-04 09:07
    关注

    this link may help , http://davidwalsh.name/custom-missing-image

    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 });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?