再IE下应该是可用的:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<title>Untitled</title>
</head>
<script language="JavaScript">
function trim(str)
{
regExp1 = /^ */;
regExp2 = / *$/;
return str.replace(regExp1,'').replace(regExp2,'');
}
var i=0;
function show(){
document.Form1.a.value=document.Form1.UploadFileBox.value;
// document.Form1.UploadFileBox.value = trim(document.Form1.UploadFileBox.value);
document.all.preview.src = document.Form1.UploadFileBox.value;
var showimg = new Image();
showimg.src = document.Form1.UploadFileBox.value;
if(showimg.width >= 400){
var ori_w= showimg.width;
var ori_h = showimg.height;
showimg.width = 400;
showimg.height = ori_h * showimg.width / ori_w;
} else {
if(showimg.height >= 400){
var ori_w2= showimg.width;
var ori_h2 = showimg.height;
showimg.height = 400;
showimg.width = ori_w2 * showimg.height / ori_h2;
} else{
showimg.height = showimg.height;
showimg.width = showimg.width;
}
}
document.all.preview.style.width = showimg.width;
document.all.preview.style.height = showimg.height;
}
</script>
<body><form name="Form1" method="post" action="UploadImage.aspx?classid=1" id="Form1" enctype="multipart/form-data">
............
<input type="text" name ="a">
<TD><input name="UploadFileBox" id="UploadFileBox" type="file" style="WIDTH: 352px; HEIGHT: 22px" size="39" onpropertychange ="show()" ></TD>
............</form>
<img src="aaa.gif" id="preview" height="200" width=400></body>
</html>
<head>
<title>Untitled</title>
</head>
<script language="JavaScript">
function trim(str)
{
regExp1 = /^ */;
regExp2 = / *$/;
return str.replace(regExp1,'').replace(regExp2,'');
}
var i=0;
function show(){
document.Form1.a.value=document.Form1.UploadFileBox.value;
// document.Form1.UploadFileBox.value = trim(document.Form1.UploadFileBox.value);
document.all.preview.src = document.Form1.UploadFileBox.value;
var showimg = new Image();
showimg.src = document.Form1.UploadFileBox.value;
if(showimg.width >= 400){
var ori_w= showimg.width;
var ori_h = showimg.height;
showimg.width = 400;
showimg.height = ori_h * showimg.width / ori_w;
} else {
if(showimg.height >= 400){
var ori_w2= showimg.width;
var ori_h2 = showimg.height;
showimg.height = 400;
showimg.width = ori_w2 * showimg.height / ori_h2;
} else{
showimg.height = showimg.height;
showimg.width = showimg.width;
}
}
document.all.preview.style.width = showimg.width;
document.all.preview.style.height = showimg.height;
}
</script>
<body><form name="Form1" method="post" action="UploadImage.aspx?classid=1" id="Form1" enctype="multipart/form-data">
............
<input type="text" name ="a">
<TD><input name="UploadFileBox" id="UploadFileBox" type="file" style="WIDTH: 352px; HEIGHT: 22px" size="39" onpropertychange ="show()" ></TD>
............</form>
<img src="aaa.gif" id="preview" height="200" width=400></body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货