Explorar o código

Handle history back/forward in mc/xxx pages

Vijayakrishnan %!s(int64=5) %!d(string=hai) anos
pai
achega
664bc5642b
Modificáronse 2 ficheiros con 9 adicións e 0 borrados
  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>