Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('document').ready(function () {
  2.     $('#contentHolder').on('click', '.historyAPI', function (e) {
  3.         e.preventDefault();
  4.         var href = $(this).attr('href');
  5.         getContent(href, true);
  6.     });
  7. });
  8.  
  9.  
  10. window.addEventListener("popstate", function (e) {
  11.     getContent(location.pathname, false);
  12. });
  13.  
  14.  
  15. function getContent(url, addEntry) {
  16.     $(function () {
  17.         $("#contentHolder").load(url);
  18.     });
  19.  
  20.     if (addEntry == true) {
  21.         history.pushState(null, null, url);
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement