How to Detect Browser Back Button event - Cross Browser

后端 未结 16 3052
鱼传尺愫
鱼传尺愫 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-21 23:45

     
    
    
     $(document).ready(function () {
            if ($("#__pageLoaded").val() != 1) {
    
                $("#__pageLoaded").val(1);
    
    
            } else {
                shared.isBackLoad = true;
                $("#__pageLoaded").val(1);  
    
                // Call any function that handles your back event
    
            }
        });
    

    The above code worked for me. On mobile browsers, when the user clicked on the back button, we wanted to restore the page state as per his previous visit.

提交回复
热议问题