IE9双表格提交问题 [英] IE9 Double Form Submit Issue

查看:149
本文介绍了IE9双表格提交问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否有人对我所处的情况有一些信息或反馈。
目前我正面临双表格提交问题,我点击提交按钮,然后提交表格两次。这只发生在IE9中,但我只测试过Safari,Chrome(最新版本),FF(版本5/6),IE8和IE9。

这里是code:

 <!DOCTYPE html> 
< html lang =en-usdir =ltr>
< head>
< meta charset =utf-8/>
< meta http-equiv =X-UA-Compatiblecontent =IE = edge>
< title> IE9测试< / title>
< / head>
< body>
< h1>测试< / h1>
< form method =POSTid =submit_form>
< input type =textname =xvalue =xxxx/>
< input type =textname =yvalue =yyyy/>
< button type =submitclass =btn_sign_inid =btn_logononclick =this.disabled = true; document.forms [0] .submit();>提交< / button>
< / form>
< / body>
< / html>

有问题的部分是:

 的onclick = this.disabled = TRUE; document.forms [0] .submit(); 

这段代码已经在我的网站上很久了,这是我第一次遇到double submit因为IE9今年才发布的问题,可能现在越来越多的人使用IE9,因此我收到了用户对这个问题的投诉。



最难的部分是双重提交问题并不总是可重复的。有时它会加倍提交,有时它会提交一次。



我目前的工作是从以下变化:

 < meta http-equiv =X-UA-Compatiblecontent =IE = edge> 

改为:

 < meta http-equiv =X-UA-Compatiblecontent =IE = 8> 

这会强制IE9使用IE8兼容性,并且会正确执行Javascript以便提交。



我称之为微软支持,他们声称这是一个Javascript兼容性问题,所以我们需要微调我们的Javascript,让我们的网站在IE9下正常工作..( )

无论如何,我的代码是:

$ p $ onclick = this.disabled = TRUE; document.forms [0] .submit();

在开始时已经是错误的了吗?因为即使其他浏览器不抱怨,但可能这是不正确的开始?



我希望如果有人也面临类似的问题有更多的信息或反馈。
目前,如果我不更改X-UA兼容IE = 8,我可以更改我的代码为:

 的onclick = this.disabled = TRUE; 

这也解决了双重提交问题,但是还有一个IE9兼容性问题列表,应该注意些什么?



谢谢!

解决方案

此代码错误:

 的onclick = this.disabled = TRUE; document.forms [0] .submit(); 

onclick Javascript并不保证正常提交不会执行。为此,它需要返回false,如下所示:

  onclick =this.disabled = true; document.forms [0] .submit();返回false; 

这种行为变化是一个IE9错误吗?这取决于,这可能取决于时间问题导致的法律行为。如果DOM / Javacript标准保证document.submit()是文档中所有执行的结束,那只是一个错误。我怀疑是这种情况。


I am just wondering if anyone have some info or feedback about the situation I am in. Currently I am facing a "Double Form Submit" issue, where I click the "Submit" button once, and it submit the form twice. This only happens in IE9, but I have only tested against Safari, Chrome (Latest), FF (Ver 5/6), IE8, and IE9.

Here is the code:

<!DOCTYPE html>
<html lang="en-us" dir="ltr">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" >
<title>IE9 test</title>
</head>
<body>
<h1>Testing</h1>
<form method="POST" id="submit_form">
<input type="text" name="x" value="xxxx" />
<input type="text" name="y" value="yyyy" />
<button type="submit" class="btn_sign_in" id="btn_logon" onclick="this.disabled=true;document.forms[0].submit();">Submit</button>
</form>
</body>
</html>

The problematic part is:

onclick="this.disabled=true;document.forms[0].submit();"

The code has been in my site for ages, and this is the first time I have encountered double submit problem since IE9 only releases this year, and probably these days more and more people using IE9, and hence I have received users complaints about this problem.

The hardest part is that the double submit problem is not always reproducible. Sometimes it will double submit, sometimes it will submit once.

My current work around is change from:

<meta http-equiv="X-UA-Compatible" content="IE=edge" >

and change to:

<meta http-equiv="X-UA-Compatible" content="IE=8" >

This forces IE9 to use IE8 compatibility and it will execute the Javascript properly for for submission.

I have called Microsoft support, and they claim this is a "Javascript compatibility issue", so we will need to fine tune our Javascript to have our site work properly under IE9..(Duh!)

Anyway, is my code:

onclick="this.disabled=true;document.forms[0].submit();"

is already wrong to begin with? Because even though other browsers are not complaining, but probably this is not right to be begin with?

I am hoping if someone also faces similar issues have some more info or feedback. Currently if I don't change X-UA-Compatible to IE=8, I can change my code to:

onclick="this.disabled=true;"

This will also solve the double submit issue, but is there also a list of IE9 compatibility issues that we should take note on?

Thanks!

解决方案

This code is wrong:

onclick="this.disabled=true;document.forms[0].submit();"

The onclick Javascript does not guarantee that the normal submit will not execute as well. For that it needs to return false, like this:

onclick="this.disabled=true;document.forms[0].submit(); return false;"

Is this change in behavior an IE9 bug? It depends, this could depend on legal behavior that is the result of timing issues. It's only a bug if the DOM/Javacript standard guarantees that the document.submit() is the end of all execution in a document. I doubt that this is the case.

这篇关于IE9双表格提交问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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