0

on Window.onload form is not loading My code is :

<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>

I want file select box on window onload

4

1 回答 1

0

您的功能正在运行,但您没有对该功能做任何事情。你只是得到了 elemant 就是这样。

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

window.onload=formOnWindowLoad();
function formOnWindowLoad(){
 setTimeout(function(){
 document.getElementById('uploadFileOnRemoteServer').click()},500);
}
<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>

这对你有用。如果这是你的要求。它将在 3 秒后打开。

通过这个链接...

于 2016-02-19T10:14:58.953 回答