使用 jquery 在浏览器中禁用后退按钮? [英] Disable Back Button in Browser using jquery?

查看:28
本文介绍了使用 jquery 在浏览器中禁用后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户为此单击注销时,我想禁用后退按钮,我只删除该用户的 cookie,而不是我的应用程序中的会话.并想禁用后退按钮

I would like to Disable Back button when user click on logoff for this i delete only cookies of that user not session in my application. And want to disable Back button

if(getCookie('username') == ""){
   Disable back button;// we use "window.history.redirect" for javascript i look jquery for this

}

请帮帮我..

推荐答案

你必须在 pushState 中推送你的 url 并清理浏览器历史记录:

you must push your url in pushState and clean the browser history:

试试这个:

$(document).ready(function() {
        window.history.pushState(null, "", window.location.href);        
        window.onpopstate = function() {
            window.history.pushState(null, "", window.location.href);
        };
    });

这篇关于使用 jquery 在浏览器中禁用后退按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆