在弹出窗口中提交表单不适用于Firefox和IE8 / IE9 [英] Submit form in popup window does not work in Firefox and IE8/IE9

查看:106
本文介绍了在弹出窗口中提交表单不适用于Firefox和IE8 / IE9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这种简单的方式在弹出窗口中提交表单(这需要使用vanilla JS完成)

 < form onsubmit =CheckoutProducts.onSubmitForm(this); action =/ product /
method =postname =paymentFormid =paymentForm>

这是我的JS代码

  var CheckoutProducts = CheckoutProducts || {
onSubmitForm:function(form){
window.open('','formpopup','width = 400,height = 400,resizeable,scrollbars');
form.target ='formpopup';
document.paymentForm.submit();






它在Chrome中工作正常,但由于某种原因它在Firefox和IE中不起作用,它只是打开空白页弹出,我做错了什么?

解决方案

非常简单的方法是使用经过测试的组件,它可以在所有主流浏览器中以相同的方式运行。

$(#dialog).dialog ({autoOpen:false}); $(#opener).click(function(){$(#dialog).dialog(open);}); < link rel =stylesheethref =// code.jquery.com/ui/1.11 p>

 0.4 /主题/平滑度/ jquery的-ui.css> < script src =// code.jquery.com/jquery-1.10.2.js\"> ;</script> < script src =// code.jquery.com/ui/1.11.4/jquery-ui.js\"> ;</script><button id =opener>打开对话框< / button> < div id =dialogtitle =Dialog Title>我是对话框< / div>  


I am using this simple way to submit a form in a pop up window (which need to be done with vanilla JS)

<form onsubmit="CheckoutProducts.onSubmitForm(this);" action="/product/"
method="post" name="paymentForm" id="paymentForm">

and this is my JS code

var CheckoutProducts = CheckoutProducts || {
    onSubmitForm: function(form) {
        window.open('', 'formpopup','width=400,height=400,resizeable,scrollbars');
        form.target = 'formpopup';
        document.paymentForm.submit();
    }
}

It is working fine in Chrome, but for some reason it is not working in Firefox and IE, it just opens the pop up with the blank page, What am I doing wrong?

解决方案

Very simple would be to use tested component that works in all major browsers in the same way.

$( "#dialog" ).dialog({ autoOpen: false });
$( "#opener" ).click(function() {
  $( "#dialog" ).dialog( "open" );
});

  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title">I'm a dialog</div>

这篇关于在弹出窗口中提交表单不适用于Firefox和IE8 / IE9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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