fanteathy 发表于 2012-09-25 15:12

关于在图片加载时用jQuery调整图片大小的问题

图片在类名为bodyLeft的层中,现在文档加载时用jQuery调整图片的大小,代码如下:$(".bodyLeft img").load(function(){
    w=$(this).width();
    h=$(this).height();
    t=$(this).attr("title");
    src=$(this).attr("src");
    $(this).width(w>400?400:w);
    $(this).height(w>400?(400/w)*h:h);
    $(this).css("cursor","pointer");
    $(this).click(function(){
      $("#picDlg").html("<img src="+src+" border=0/>").fadeIn(1000).dialog({
            width:"auto",
            height:"auto",
            title:t,
            modal:true,
            draggable:false,
            resizable:false
      })
    })
})此处出现一种情况:若图片加载过一次,再访问时,会显示浏览器缓存的内容而不是重新加载图片,刚上述事件不会发生,图片依然以原尺寸显示。需要主动再加载一次,上述事件才能发生。另外在IE中上述事件也并不会发生。请教解决方案。
页: [1]
查看完整版本: 关于在图片加载时用jQuery调整图片大小的问题