我正在从 javascript 提交一个表单,它在 form.submit() 处给出错误。
HTML:
<form >
<input type="file" name="filetype" onchange="uploadFile(this.form);" name="file" />
</form>
JS:
function uploadFile(form){
var iframe = document.createElement("iframe");
iframe.setAttribute("id", "upload_iframe");
iframe.setAttribute("name", "upload_iframe");
form.parentNode.appendChild(iframe);
form.setAttribute("target", "upload_iframe");
form.setAttribute("action", "abcd.do");
form.setAttribute("method", "post");
form.setAttribute("enctype", "multipart/form-data");
form.setAttribute("encoding", "multipart/form-data");
form.submit(); /// error is here (SCRIPT5: Access denied)
}
我尝试将 iframe 的源作为文件放在同一个域中,但这也不起作用。这在MOZILLA中非常有效,但在IE中给出了描述的错误。