1. 程式人生 > >js返回上一頁並重新整理

js返回上一頁並重新整理

/點選瀏覽器上的返回按鈕,返回上一頁並重新整理

  $(document).ready(function($) {
      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 === '') { self.location=document.referrer; } } }); window.history.pushState(null, null, ''); } });