Created
February 25, 2013 20:26
-
-
Save magcks/5032982 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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