要在页面显示的图片的标签 为
 <img src='" + s_pic2.InnerXml.ToString() + "' width=\"500px\"  height=\"300px\"/>"
  其中  s_pic2.InnerXml.ToString()  为通过webservice 获取的  图片的 http地址 ,这样获取的图片有的大有的小我想让它大于 500*300时 以 500*300 显示,小于 500*300时 则原样显示 ,控制方法最好就写在  img 标签里

解决方案 »

  1.   

    <img src="images/sj.gif"  onload="test(this)"/>js:
            function test(obj) {
                if (obj.width >= 500) {
                    obj.width = 500;
                    obj.height = 300;
                }
            }
      

  2.   

     不能用js啊判断的逻辑直接写在 img 标签里 
      

  3.   

    html代码就是可以加入js的!!
    楼主先做一下我给你静态的!,然后在做动态的!!
      

  4.   

      <img src="images/sj.gif" onload="test(this)"/>  我是要写到数据库里的,难道 <script type="text/script">  function test(obj) {
      if (obj.width >= 500) {
      obj.width = 500;
      obj.height = 300;
      }
      }<script>
    也要写到数据库里吗  
      

  5.   

    <img src='" + s_pic2.InnerXml.ToString() + "' onload="if(this.width>500) this.width=500;if(this.height)>300 this.height=300;"/>
      

  6.   

    <script language="JavaScript"> 
    var flag=false; 
    function DrawImage(ImgD){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width/image.height>= 140/120){ 
    if(image.width>140){ 
    ImgD.width=140; 
    ImgD.height=(image.height*140)/image.width; 
    }else{ 
    ImgD.width=image.width; 
    ImgD.height=image.height; 


    else{ 
    if(image.height>120){ 
    ImgD.height=120; 
    ImgD.width=(image.width*120)/image.height; 
    }else{ 
    ImgD.width=image.width; 
    ImgD.height=image.height; 




    </script> 
    onload="javascript:DrawImage1(this)">
    使用地址获取图片,缩略图
      

  7.   

      这个是没有办法写在 img 标签里的