单击浏览器后退按钮时,在页面上禁用提交按钮

问题描述:

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

enter image description here

您应该能够实现,使用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 
        }); 

       } 
      });