【问题标题】:Disable submit button on a page when browser back button is clicked单击浏览器后退按钮时禁用页面上的提交按钮
【发布时间】:2015-11-02 18:04:48
【问题描述】:

单击浏览器的后退按钮时,我需要禁用页面上的提交按钮。这应该是我放置此脚本的任何页面的通用含义,它应该在用户点击浏览器后退按钮时禁用该页面上的所有提交按钮。

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    您应该能够使用 window.history.pushState 和 popstate 来实现这一点(参见下面的示例)。 有关兼容性,请参阅this
    如需完整文档,请参阅this

    jQuery(document).ready(function ($) {
    
                    if (window.history && window.history.pushState) {
    
                        window.history.pushState('forward', null, null);
    
                        $(window).on('popstate', function () {
                           //Add logic here
                        });
    
                    }
                });
    

    【讨论】:

      猜你喜欢
      • 2012-11-08
      • 1970-01-01
      • 2023-03-07
      • 2016-12-25
      • 2012-12-08
      • 1970-01-01
      • 2011-08-06
      • 2010-10-31
      相关资源
      最近更新 更多