How to Detect Browser Back Button event - Cross Browser

后端 未结 16 3211
鱼传尺愫
鱼传尺愫 2020-11-21 23:09

How do you definitively detect whether or not the user has pressed the back button in the browser?

How do you enforce the use of an in-page back button inside a sin

16条回答
  •  天命终不由人
    2020-11-22 00:05

    See this:

    history.pushState(null, null, location.href);
        window.onpopstate = function () {
            history.go(1);
        };
    

    it works fine...

提交回复
热议问题