Iframe Innerhtml Is Null
this same code was working yesterday, iframe[0].contentWindow.document.body.innerHTML has value 'success'. But, today iframe[0].contentWindow.document.body is ''. I cannot find inn
Solution 1:
Using different path to iframe innerHtml worked:
JS:
functionfileUpload(form, action_url) {
var iframe = document.createElement("iframe");
iframe.setAttribute("id", "frame");
iframe.setAttribute("name", "frame");
iframe.setAttribute("width", "0");
iframe.setAttribute("height", "0");
iframe.setAttribute("frameborder", "0");
form.parentNode.appendChild(iframe);
iframeId = document.getElementById("frame");
var eventHandler = function () {
if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
else iframeId.removeEventListener("load", eventHandler, false);
if (iframeId.contentDocument) {
content = iframeId.contentDocument.body.innerHTML;
} elseif (iframeId.contentWindow) {
content = iframeId.contentWindow.document.body.innerHTML;
} elseif (iframeId.document) {
content = iframeId.document.body.innerHTML;
}
setTimeout('iframeId.parentNode.removeChild(iframeId)', 200);
}
if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);
form.setAttribute("target", "frame");
form.setAttribute("action", action_url);
form.setAttribute("method", "post");
form.submit();
}
Html:
<form><inputtype="file"name="file" /></br><inputtype="button"value="upload"onClick="fileUpload(this.form,'url'); return false;" ></form>
Post a Comment for "Iframe Innerhtml Is Null"