1. if(window.history && window.history.pushState) {
    2. $(window).on('popstate', function() {
    3. var hashLocation = location.hash;
    4. var hashSplit = hashLocation.split("#!/");
    5. var hashName = hashSplit[1];
    6. if(hashName !== '') {
    7. var hash = window.location.hash;
    8. if(hash === '') {
    9. alert("你点击了返回键");
    10. }
    11. }
    12. });
    13. window.history.pushState('forward', null, '#');
    14. }