浏览代码

Handle history back/forward in mc/xxx pages

Vijayakrishnan 5 年之前
父节点
当前提交
664bc5642b
共有 2 个文件被更改,包括 9 次插入0 次删除
  1. 6 0
      public/js/mc.js
  2. 3 0
      resources/views/layouts/template.blade.php

+ 6 - 0
public/js/mc.js

@@ -0,0 +1,6 @@
+window.top.addEventListener('popstate', function(event) {
+    if(!!event.state) window.location = event.state;
+});
+$(document).ready(function() {
+    window.top.history.replaceState(window.location.pathname, null, '/mc' + window.location.pathname);
+});

+ 3 - 0
resources/views/layouts/template.blade.php

@@ -74,6 +74,9 @@
 
     </main><!-- /.container -->
 
+    <!-- script to handle history & back/forward for mc/xxx pages -->
+    <script src="{{ asset('js/mc.js') }}" type="application/javascript"></script>
+
 </body>
 
 </html>