xpengfee
      1.之前控制图片显示大小都是用像下面这样:
<img onload=\'javascript:if(this.width>620){this.style.width=620} if(this.height>400){this.style.height=400}\' alt="" src="http://bbs.qq.com/images/act.gif" border=0> 
如果图片大于指定大小,将图片大小设成所指定的大小,避免图片过大破坏网页原有布局。
      由于图片路径要在后台动态绑定,所以用了服务器控件<asp:Image>,但这样一来用 onload就不行了。调了一会发现这条路不通。所以直接换成后台的:
         imgPhoto.Attributes.Add("onload", "javascript:if(this.width>200){ this.style.width=200;} if(this.height>150){ this.style.height=150;}");
         imgSign.Attributes.Add("onload", "javascript:if(this.width>200){ this.style.width=200;} if(this.height>150){ this.style.height=150;}");
这样一来就OK了。

分类:

技术点:

相关文章:

  • 2021-09-24
  • 2021-08-13
  • 2021-11-28
  • 2021-11-13
  • 2021-08-13
  • 2022-01-01
  • 2022-01-01
  • 2022-02-01
猜你喜欢
  • 2021-12-28
  • 2021-12-28
  • 2021-11-18
  • 2021-08-13
  • 2021-12-01
  • 2021-04-11
  • 2021-12-26
相关资源
相似解决方案