Skip to content

Instantly share code, notes, and snippets.

@magcks
Created February 25, 2013 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magcks/5032982 to your computer and use it in GitHub Desktop.
Save magcks/5032982 to your computer and use it in GitHub Desktop.
var popped = ('state' in window.history),
initialURL = window.location.href;
window.onpopstate = function(event) {
var initialPop = !popped && location.href == initialURL;
popped = true;
if (initialPop) return false;
var state = event.state;
var path = state.path,
method = state.method;
loadContent(path, method);
};
function loadContent(path, method) {
// Inhalt vom server laden via AJAX, dann:
refreshAdsense();
}
function refreshAdsense() {
// Hier wird die Anzeige neu geladen
}
function linkClicked(path) {
if (typeof window.history.pushState !== 'function') return true; // Klassische weiterleitung nutzen, da pushState nicht vorhanden.
window.history.pushState({
path: path,
method: 'get',
}, undefined, path);
return false; // Weiterleitung verhinden
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment