【PHP】安卓手机监听物理返回按键

版权声明:咔咔 来自https://blog.csdn.net/fangkang7 https://blog.csdn.net/fangkang7/article/details/83866933
if(window.history && window.history.pushState) {
    $(window).on('popstate', function() {
        var hashLocation = location.hash;
        var hashSplit = hashLocation.split("#!/");
        var hashName = hashSplit[1];
        if(hashName !== '') {
            var hash = window.location.hash;
            if(hash === '') {
                alert("你点击了返回键");
            }
        }
    });
    window.history.pushState('forward', null, '#');
}

猜你喜欢

转载自blog.csdn.net/fangkang7/article/details/83866933