Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var XMLHttpRequest = XMLHttpRequest || window.ActiveXObject && function () {
- return new ActiveXObject('Msxml2.XMLHTTP');
- };
- function get_s(url) {
- var xhr = new XMLHttpRequest();
- xhr.open('get', url, false);
- xhr.send(null);
- return xhr.responseText;
- }
- window.onload = function () {
- var link = document.getElementById('historyAPI');
- link.addEventListener("click",
- function (e) {
- e.preventDefault();
- getContent(link, true);
- }, true
- );
- };
- window.addEventListener("popstate", function (e) {
- getContent(location.pathname, false);
- });
- function getContent(link, addEntry)
- {
- var url = link.href.replace(/^.*?:\/\/.*?(?=\/|$)/, '');
- var result = get_s(url);
- contentHolder.innerHTML = result;
- if (addEntry === true) {
- history.pushState(null, null, link.href);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement