Advertisement
krot

address history back reload

Nov 19th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.59 KB | None | 0 0
  1.  
  2.  
  3. var visitedPages = [$.address.path()];
  4. var first_load = true;
  5.  
  6. $.address.internalChange(function() {
  7.  
  8.    visitedPages.push($.address.path());
  9.  
  10. });
  11.  
  12. $.address.externalChange(function() {
  13.  
  14.     var newPage = $.address.path();
  15.  
  16.     if (visitedPages[visitedPages.length-2] == newPage) {
  17.  
  18.         console.log('back');
  19.         location.reload();
  20.         visitedPages.splice(visitedPages.length-1 , 1);
  21.  
  22.     } else if (first_load === false) {
  23.  
  24.         console.log('forward');  
  25.         location.reload();
  26.         visitedPages.push($.address.path());
  27.  
  28.     }
  29.  
  30.     first_load = false;
  31.  
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement