Created
April 26, 2014 19:30
-
-
Save datamafia/11328870 to your computer and use it in GitHub Desktop.
Supporting Gist for article on web page state control
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test.html</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var stateObj = { test: "bar" }; | |
history.pushState(stateObj, "page 2", "bar.html"); | |
function alterstate(){ | |
var stateObj = { bar: "altered" }; | |
history.pushState(stateObj, "page 2", "altered.html"); | |
} | |
function returnstate(){ | |
var stateObj = { altered: "bar" }; | |
history.pushState(stateObj, "page 2", "bar.html"); | |
} | |
</script> | |
<p>Native implementation operational for Firefox.</p> | |
<p> | |
site.com/test.html shoudl automatically become read site.com/bar.html using no page reload. | |
</p> | |
<p> | |
<button onclick="alterstate()">Alter the URL</button> | |
<button onclick="returnstate()">Return the URL</button> | |
<a href="/test.html">Return to test.html</a> | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment