var img = null;
function OnUpload() {
//var id = parent.document.getElementById("baEntity.id").value;
var id = parent.key;
if (id == -1) {
alert("请先录入步骤一");
return false;
} else {
if (img)
img.removeNode(true);
img=document.createElement("img");
img.style.position = "absolute";
img.style.visibility = "hidden";
img.attachEvent("onreadystatechange",OnStateChange);
img.attachEvent("onerror",OnError);
document.body.insertAdjacentElement("beforeend", img);
img.src = $("#txtFile").val();
}
}
function OnError() {
alert("支持JPG,PNG,GIF,BMP,JPEG格式的图片上传!");
}
function OnStateChange(){
alert("dsdsd");
if (img.readyState != "complete")
return false;
if (CheckValidate()) {
if (img.fileSize < 5242880) {
document.forms[0].action = "FileUpload.do?uploadtype=1"+"&picturetype="+picturetype;
document.forms[0].submit();
} else {
alert("图片大小不能超过5M!");
return false;
}
}
}
function CheckValidate() {
var dirUrl = document.getElementById("txtFile").value;
if (dirUrl == null || dirUrl == "") {
alert('文件路径不能为空!');
return false;
} else
return IsValidateFile(dirUrl);
}
onreadystatechange是相应xmlHttpRequest.readyState的吧。