例如最大显示为800*600??

解决方案 »

  1.   

    用image控件,在服务端判断图片大小后在发到页面上来
      

  2.   

    image类,将image文件读入,获取height,width,进行判断即可,小的按实际大小显示,大的800*600
      

  3.   

    String scriptString = "<script language=JavaScript>";
    scriptString += "if(document.all." + Image1.ClientID + ".height>100) document.all." + Image1.ClientID + ".height = 100";
    scriptString += "</script>";
            
    if(!this.IsStartupScriptRegistered("Startup"))
    this.RegisterStartupScript("Startup", scriptString);
      

  4.   

    我现在用的是javascript 在htc中处理,没法调用.net的那些类啊。
    var newNode = document.createElement("img");
    newNode.src =  url;
    if(newNode.width>700)
    newNode.width=700;
    if(newNode.height>525)
    newNode.height=525;
    不行,第一次打开的时候总是会按照图片原大小显示,再次打开就会没事了
      

  5.   

    在客户端用脚本实现很容易的。楼上的脚本改一下就行了".height"改成".offsetHeight"
    img不要指定它的width,和height,因为你也不知道。
      

  6.   

    <img ... onLoad="if(this.offsetWidth>=800{this.width=800;})">
    这样可以么
      

  7.   

    img 没有onload事件,所以得放在<body onload>或者这个<img>被标记的下边的<script>里边
      

  8.   

    moonewxp(母牛) ( )
    这个具体应该怎么做啊?
      

  9.   

    直接修改不行,默认情况offsetWidth=0,如果直接设置offsetWidth=800,图片直接就不显示了,还不知道offset的显示到那个地方去了呢
      

  10.   

    onload也没法的到图片文件到底是多height,width啊
      

  11.   

    <img> 标签自己就有 width/height 属性,设置后会自动缩放,只是缩放后的效果差点罢了。
      

  12.   

    <script>
    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>= 90/90){
         if(image.width>90){  
         ImgD.width=90;
         ImgD.height=(image.height*90)/image.width;
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         }
        else{
         if(image.height>90)
     {  
         ImgD.height=90;
         ImgD.width=(image.width*90)/image.height;     
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         }
        }
    } </script><body>
    <img src="shop/smallimg.gif" onload="javascript:DrawImage(this);" border="0">
    </body>
      

  13.   

    esponse.Write(ImageButton1.ImageUrl);
                         System.Drawing.Image logo = System.Drawing.Image.FromFile(Server.MapPath(ImageButton1.ImageUrl));
                         Response.Write(logo.Width);
                         Response.Write(logo.Height);
                         logo.Dispose();
      

  14.   

    在img中把图片宽度死就可以了,图片按比例自动缩小。
      

  15.   

    lijianlee(小楼昨夜又东风)的方法可用,但是仍然有一个问题。
      图片的形状有时候不会是很规则,有时候需要限制 长度,该怎么办?
      

  16.   

    var image=new Image();
       image.src=ImgD.src;
    之后
       if(image.width>0 && image.height>0)能够得到图片的大小吗?好像不行吧