在 Firefox 中使用“后退”按钮时,表单提交按钮保持禁用状态

发布于 2024-08-19 19:47:22 字数 137 浏览 5 评论 0原文

我正在使用一些 jquery 在单击表单提交按钮后禁用它,以防止意外重复单击。这在除 Firefox 之外的所有浏览器中都可以正常工作。在 Firefox 中,如果用户在提交按钮禁用后使用浏览器后退按钮返回页面,则提交按钮仍会被禁用。这个问题有什么解决办法吗?

I'm using some jquery to disable a form submit button after it's been clicked to prevent accidental repeated clicking. This works fine in all browsers except Firefox. In Firefox if the user uses the browser Back button to go back to a page after the submit button disabling has occurred, the submit button is still disabled. Is there any solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江南月 2024-08-26 19:47:22

也许,您应该在表单中添加 autocomplete="off" 参数

<form autocomplete="off">
  <input type="submit" />
</form>

Probably, you should add autocomplete="off" parameter to your form

<form autocomplete="off">
  <input type="submit" />
</form>
一个人的旅程 2024-08-26 19:47:22
$(document).ready(function() {
    $('input[type=submit]', this).attr('disabled', false);

    $('#myform').submit(function(){
        $('input[type=submit]', this).attr('disabled', true);
    });    

});

使用 jQuery,这将使按钮在使用浏览器上的后退按钮时不会被禁用。在 FF 3.5 上测试。

$(document).ready(function() {
    $('input[type=submit]', this).attr('disabled', false);

    $('#myform').submit(function(){
        $('input[type=submit]', this).attr('disabled', true);
    });    

});

Using jQuery, this will make the button not disabled upon using the back-button on the browser. Tested on FF 3.5.

沐歌 2024-08-26 19:47:22

如果浏览器禁用了缓存,则页面将重新加载,就好像什么也没发生一样(没有单击按钮)。

如果你想要客户端,你可以使用cookie。

现在,如果您有服务器端技术(PHP/Rails),那么您可以将该值放入会话变量中。

If a browser has caching disabled, then the page will be reloaded as if nothing had happened (no button clicked).

If you want client side, you could use a cookie.

Now, if you have a a server side technology (PHP/Rails), then you could put the value in the session variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文