提交带有iFrame目标的表单
问题描述:
我想在与表单相同的页面上将表单提交到iFrame中。
我正在使用Target =iframe_results,其中iframe_results是iframe的名称。
I want to submit a form into an iFrame on the same page as the form. I'm using Target="iframe_results" where iframe_results is the name of the iframe.
这在Firefox和Chrome中运行正常但在IE中它会弹出一个新的标签/窗口。
This works fine in Firefox and Chrome but in IE it pops open a new tab/window.
我尝试使用JavaScript进行提交(如其他来源所述),但这仍然没有用。
I tried using JavaScript to do the submits (as outlined in other sources) but this still didnt work.
答
您使用的是哪个版本的IE?我已经实现了这种方法而没有任何问题
What version of IE are you using? I've implemented this method without having any issues whatsoever
http://www.openjs.com/articles/ajax/ajax_file_upload/
<form id="file_upload_form" method="post" enctype="multipart/form-data" action="upload.php">
<input name="file" id="file" size="27" type="file" /><br />
<input type="submit" name="action" value="Upload" /><br />
<iframe id="upload_target" name="upload_target" src="" style="width:0;height:0;border:0px solid #fff;"></iframe>
function init() {
document.getElementById('file_upload_form').onsubmit=function() {
document.getElementById('file_upload_form').target = 'upload_target'; //'upload_target' is the name of the iframe
}
}