提交带有iFrame目标的表单 [英] Submitting a form with an iFrame target

查看:141
本文介绍了提交带有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
    }
}

这篇关于提交带有iFrame目标的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆