js代码是把名称为ima1的图片加载时按比例显示,我的图片是放在repeat里面的,图片必须是runat="server"的,因为我后台要用到,
我自己写好的js兼容了ie和ff,但是google不行,高手帮忙看一下:
function proDownImage(ImgD){
   
       var checkboxid=  document.getElementsByName('ima1');      
       for(var i=0;i<checkboxid.length;i++){  
                  
            var image=new Image();            
               
      image.src=checkboxid[i].src;
      if(image.width>0 && image.height>0){
      var rate = (100/image.width < 100/image.height)?100/image.width:100/image.height;
    if(rate <= 1){   
     checkboxid[i].width = image.width*rate;
     checkboxid[i].height =image.height*rate;
    }
    else {
                          checkboxid[i].width = image.width;
                          checkboxid[i].height =image.height; }
      }
}
}

解决方案 »

  1.   

    用jquery 控制他的图片大小应该可以吧。 
      

  2.   

    var checkboxid=  document.getElementsByName('ima1'); 确定你的对象获取到了。用alert(checkboxid);实验下
      

  3.   


    var checkboxid=document.getElementsByName('ima1');      
        for(var i=0;i<checkboxid.length;i++){  
             var image=new Image();            
                   
             image.src=checkboxid[i].src;
             if(image.width>0 && image.height>0){
           var rate = (100/image.width < 100/image.height)?100/image.width:100/image.height;
    alert(rate);
    if(rate <= 1){   
     checkboxid[i].style.width = image.width*rate+"px";
     checkboxid[i].style.height =image.height*rate+"px";
    }
    else {
     checkboxid[i].style.width = image.width+"px";
     checkboxid[i].style.height =image.height+"px";
       }
    }
    }
    你尝试一下,我觉得应该可以解决!(不肯定啊!)
      

  4.   

    这个能兼容google了,但是不稳定,我刷新一下,有时候图片都不见了,再刷新一下就会出来一些,之类的事情……继续盼望高手指导
      

  5.   

    我调试了下方法,还是不能兼容google
      

  6.   

    我用jquery做了个,兼容了google,但是img里面的onclick方法却运行不了了
      

  7.   

    看看是否有脚本报错,贴你那个img的click方法出来!
      

  8.   


    这是我的测试网址,我要解决的是google的图片没有按比例压缩那回事,其他脚本已经写好,只有上面的那个脚本在google里面存在问题,其他浏览器都蛮好的http://test.yoyard.cn/Twitter/Default.aspx?saysType=1
      

  9.   

    帮不上你了!我这里没有google浏览器,只有火狐和IE,期待高手
      

  10.   

    结贴了,还是没有得到正确答案,再找吧,google啊,无赖中