<input type="file" name=”file1”> file中的value是只读的,不能通过document.all.file1.value=”c:\tmep\*.*”,这也是基于安全的考虑。
但不是不能为file设置默认值(只支持WINWOWS)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function init(){
document.all.file1.focus();
var WshShell=new ActiveXObject("WScript.Shell");
WshShell.sendKeys("C:\\WINDOWS\\System.dat");
}
</script>
</HEAD>
<BODY onload="init()">
<input id="file1" type="file" name="file1">
</BODY>
</HTML>