私はこのような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
問題を見つけて修正するのを手伝ってください。
よろしくお願いします