Skip to content

Instantly share code, notes, and snippets.

@datamafia
Created April 26, 2014 19:30
Show Gist options
  • Save datamafia/11328870 to your computer and use it in GitHub Desktop.
Save datamafia/11328870 to your computer and use it in GitHub Desktop.
Supporting Gist for article on web page state control
<!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