最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Submitting a form with an iFrame target - Stack Overflow

programmeradmin4浏览0评论

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.

This works fine in Firefox and Chrome but in IE it pops open a new tab/window.

I tried using JavaScript to do the submits (as outlined in other sources) but this still didnt work.

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.

This works fine in Firefox and Chrome but in IE it pops open a new tab/window.

I tried using JavaScript to do the submits (as outlined in other sources) but this still didnt work.

Share Improve this question asked Mar 31, 2011 at 5:02 ErnestErnest 8244 gold badges12 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 1

What version of IE are you using? I've implemented this method without having any issues whatsoever

http://www.openjs./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
    }
}
发布评论

评论列表(0)

  1. 暂无评论