Advertisement
Guest User

Untitled

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