JavaScript

超轻量级php框架startmvc

js禁止浏览器页面后退功能的实例(推荐)

更新时间:2020-06-02 21:24 作者:startmvc
实例如下所示:<script>$(function(){if(window.location.href.indexOf("/login")>-1){//防止页面后退his

实例如下所示:


<script>
 $(function(){
 if(window.location.href.indexOf("/login") > -1) {
 //防止页面后退
 history.pushState(null, null, document.URL);
 window.addEventListener('popstate', function () {
 history.pushState(null, null, document.URL);
 });
 }
 });
</script>

以上这篇js禁止浏览器页面后退功能的实例(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。