Created
February 14, 2013 13:34
-
-
Save vishaltelangre/4952818 to your computer and use it in GitHub Desktop.
Some fun w/ HTML5's history API
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 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