图片预览程序

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<FORM id=info_form name=info_form  action=test.asp method=post  encType=multipart/form-data>
<%for i=0 to 2%>
<TABLE>
                          <TBODY>
                          <TR>
                            <TD
                            style="BORDER-RIGHT: #000 1px solid; BORDER-TOP: #000 1px solid; BORDER-LEFT: #000 1px solid; WIDTH: 180px; BORDER-BOTTOM: #000 1px solid; HEIGHT: 120px"
                            vAlign=center align=middle><IMG id=prev_icon<%=i%>
                              src="控制面板 - 个人基本信息设置.files/default_icon.jpg"
                              οnlοad="img_resize('prev_icon<%=i%>');"></TD></TR></TBODY></TABLE>
<INPUT id=fileContent<%=i%> onKeyDown="return false;" style="BORDER-RIGHT: #000 1px solid; BORDER-TOP: #000 1px solid; BORDER-LEFT: #000 1px solid; WIDTH: 180px; BORDER-BOTTOM: #000 1px solid" type=file οnchange=preview_icon<%=i%>(); name=fileContent<%=i%>>
<script language="javascript">
var br = browserDetect();
var ie = false;
if (br == 'ie6' || br == 'ie55' || br == 'ie5')
 ie = true; 
function preview_icon<%=i%>()
{
 if ( ! ie)
  return;
 def_icon = '/images/default_icon.jpg';
 if (document.info_form.fileContent<%=i%>.value == '')
  document.getElementById('prev_icon<%=i%>').src = def_icon;
 else
  document.getElementById('prev_icon<%=i%>').src = document.info_form.fileContent<%=i%>.value;
 //setTimeout("img_resize('prev_icon')", 1000);
}
function browserDetect(){
 var sUA = navigator.userAgent.toLowerCase();
 var sIE = sUA.indexOf("msie");
 var sOpera = sUA.indexOf("opera");
 var sMoz = sUA.indexOf("gecko");
 if (sOpera != -1) return "opera";
 if (sIE != -1){
  nIeVer = parseFloat(sUA.substr(sIE + 5));
  if (nIeVer >= 6) return "ie6";
  else if (nIeVer >= 5.5) return "ie55";
  else if (nIeVer >= 5 ) return "ie5";
 }
 if (sMoz != -1) return "moz";
 return "other";
}
function img_resize(id)
{
 _pObj = document.getElementById(id);
 var width = 180;
 var height = 120;
 if(_pObj.width < width && _pObj.height < height)return;
 if (width/_pObj.width < height/_pObj.height){
  _pObj.width     = _pObj.width * (width / _pObj.width);
 }
 else{
  _pObj.height    = _pObj.height * (height / _pObj.height);
 }
 //alert(_pObj.width + ' ' + _pObj.height);
}
</script>
<%next%>
</FORM>
</body>
</html> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值