在Window.onload表单上没有加载

时间:2016-02-19 10:03:09

标签: javascript window.onunload

Window.onload表单上的

未加载 我的代码是:

<script language="javascript" type="text/javascript"> 
window.onload=formOnWindowLoad();
function formOnWindowLoad(){
setTimeout(function(){document.getElementById('fileUploadForm');},3000);
}
</script>
</head>
<body >
<br>Select a file to upload: <br />
<form id="fileUploadForm" action="fileLocalUpload.htm?eId=${eId}&tId=${tId}" method="post"enctype="multipart/form-data"> 
<input id="uploadFileOnRemoteServer" type="file" name="uploadingFile" />
<br />
<input type="submit" value="Upload File" />
</form>

我想在窗口上加载文件选择框

1 个答案:

答案 0 :(得分:0)

您的功能正常,但您没有使用该功能。你只是得到了它的元素。

如果您想在一段时间后打开文件上传,此代码适合您。我一直警惕你的理解。

&#13;
&#13;
window.onload=formOnWindowLoad();
function formOnWindowLoad(){
 setTimeout(function(){
 document.getElementById('uploadFileOnRemoteServer').click()},500);
}
&#13;
<br>Select a file to upload: <br />
<form id="fileUploadForm" action="fileLocalUpload.htm?eId=${eId}&tId=${tId}" method="post"enctype="multipart/form-data"> 
<input id="uploadFileOnRemoteServer" type="file" name="uploadingFile" />
<br />
<input type="submit" value="Upload File" />
  
</form>
&#13;
&#13;
&#13;

这适合你。如果这是你的要求。它将在3秒后打开。

Go through this link...