Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Created February 14, 2013 13:34
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 vishaltelangre/4952818 to your computer and use it in GitHub Desktop.
Save vishaltelangre/4952818 to your computer and use it in GitHub Desktop.
Some fun w/ HTML5's history API
var original_url = window.location.href
var to_be_changed_url = "blah blah url"
history.pushState(null, null, '/foo.html');
window.onpopstate = function(e){
if(e.state){
history.pushState(null, null, original_url);
}
//window.location.href = to_be_changed_url;
};
document.onkeydown = function() {
switch (event.keyCode) {
case 116 : //F5 button
history.pushState(null, null, original_url);
window.location.reload();
case 82 : //R button
if (event.ctrlKey) {
history.pushState(null, null, original_url);
window.location.reload();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment