Skip to content

Instantly share code, notes, and snippets.

@screeny05
Created April 24, 2018 08:11
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 screeny05/5ddd68b18029c9b26e966fed42bb5be7 to your computer and use it in GitHub Desktop.
Save screeny05/5ddd68b18029c9b26e966fed42bb5be7 to your computer and use it in GitHub Desktop.
var historyBackWithFallback = function(url){
var originalHref = window.location.href;
var timeoutId = setTimeout(function(){
if(window.location.href !== originalHref){
return;
}
window.location = 'https://google.de';
}, 1500);
window.addEventListener('beforeunload', function(){
clearTimeout(timeoutId);
});
history.back();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment