简体   繁体   English

使用javascript进行表单提交仅适用于Google Chrome浏览器一次

[英]Form submit with javascript works in Google Chrome only once

I have simple form. 我有简单的形式。

<form target="_blank" action="somescript.php" method="Post" id="simpleForm">
<input type="hidden" name="url" value="http://...">
<input type="hidden" name="code" value="wrxosf">
</form>

...and there are some anchor link ......还有一些锚链接

<a href="#" onclick="$('#simpleForm').submit();return false;">Do it!</a>

It works fine in FireFox or IE, but Google Chrome. 它适用于FireFox或IE,但谷歌Chrome。 Chrome does once, then link become unclickable. Chrome只执行一次,然后链接变得无法点击。

Also had such problem. 也有这样的问题。

The decision was to add something random to URL each time before submitting. 决定是在每次提交之前向URL添加一些随机内容。

HTML: HTML:

<form action="go.php" method="post" target="_blank" id="go">
...
</form>

JavaScript (jQuery): JavaScript(jQuery):

$('#go').attr('action','go.php?'+Math.random()*1000).submit();

Forms with target="_blank" submiting only once. 具有target =“_ blank”的表单仅提交一次。 This is webkit & chromium bugs. 这是webkitchrome bug。

I am running Chrome 7.0.5 and also still having this problem. 我正在运行Chrome 7.0.5,但仍然遇到此问题。 Setting the action to something different each time as suggested above works! 如上所述,每次将动作设置为不同的动作! :) :)

此问题已在最新版本的Chrome 5.0.375.55

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM