我有一个 iframe 和这样的表单:
<iframe id="FileUploadFrame" name="FileUploadFrame" src="" style="display: none; border: 0; width: 0; height: 0;">
<form id="FileUploadForm" name="FileUploadForm" accept-charset="utf-8" target="FileUploadFrame" enctype="multipart/form-data" encoding="multipart/form-data" method="POST" action="CIMtrek_Regional_WhseForm_FileUpload">
</form>
</iframe>
这就是我提交表格的方式iframe
function fileUpload() {
//var UploadForm = document.forms["FileUploadForm"];
var UploadForm = global.forms["FileUploadForm"];
alert("Form : "+typeof global.forms["FileUploadForm"]);
alert("Form : "+typeof global.forms["FileUploadFrame"]);
iframeId = document.getElementById("FileUploadFrame");
// Add event...
var eventHandler = function () {
if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
else iframeId.removeEventListener("load", eventHandler, false);
// Message from server...
if (iframeId.contentDocument) {
content = iframeId.contentDocument.body.innerHTML;
} else if (iframeId.contentWindow) {
content = iframeId.contentWindow.document.body.innerHTML;
} else if (iframeId.document) {
content = iframeId.document.body.innerHTML;
}
document.getElementById(div_id).innerHTML = content;
}
if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);
//alert('submitting form');
//form.submit();
//document.forms["FileUploadForm"].submit();
alert(UploadForm.submit());
}
但提交表单时出现以下异常:
Error: Unable to get value of the property 'submit': object is null or undefined
请帮我找出问题并解决。
最好的祝福