我有一个基于 IFRAME 的上传文件。它适用于 Firefox 和 Google Chrome,但适用于 Internet Explorer 8,当您发送文件时,整个页面都会刷新。按照我的代码:
JS:
function test(){
iframe = document.createElement("IFRAME");
iframe.name = "iframe_upload";
iframe.id = "iframe_upload"; //some browsers target by id not name
document.body.appendChild(iframe);
document.getElementById("test").target = "iframe_upload";
}
HTML:
<form id="test" method="post" target="iframe_upload" enctype="multipart/form-data" onsubmit="javascript:test()" action="test.php">
<input name="image" type="file" />
<input type="submit" value="Submit" />
</form>