Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using pushState to update the URL

  • Loading branch information...
commit 4a7846ff1d507645eea2a080c6355ce790e01f0c 1 parent 2629e3c
@beaucollins authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 public/app.js
View
11 public/app.js
@@ -216,8 +216,19 @@ var loadSite = function(src){
document.querySelector('form').addEventListener('submit', function(e){
e.preventDefault();
+ if (window.history.pushState) {
+ window.history.pushState({url:this.site.value}, null, "?" + this.site.value);
+ };
loadSite(this.site.value);
});
+
+window.addEventListener('popstate', function(e){
+ if (e.state && e.state.url) {
+ console.log("State", e.state);
+ document.forms[0].site.value = e.state.url;
+ loadSite(e.state.url)
+ };
+});
window.addEventListener('resize', function(){
span.textContent = iframe.offsetWidth + 'px';
Please sign in to comment.
Something went wrong with that request. Please try again.