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);
}
}
window.onload = function () {
var link = document.getElementsByClassName('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)
{
alert(link.href);
if (addEntry == true) {
history.pushState(null, null, link.href);
}
}