From c150947e4ccecdecbfb095f868124dadfdb6a221 Mon Sep 17 00:00:00 2001 From: Dan Leech Date: Wed, 28 Oct 2015 15:53:06 +0000 Subject: [PATCH] Added hashchange listener --- 404.html | 13 ++++++++++--- index.html | 13 ++++++++++--- src/footer.html | 13 ++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/404.html b/404.html index d6a0040f3..1155d620b 100644 --- a/404.html +++ b/404.html @@ -388,9 +388,16 @@ search(); }); - var query = window.location.hash.substring(1); - document.getElementById("search").value = query; - search(); + hashSearch(); + window.addEventListener('hashchange', function (evt) { + hashSearch(); + }); + + function hashSearch() { + var query = window.location.hash.substring(1); + document.getElementById("search").value = query; + search(); + } function search() { var searchTerm = searchField.value.toLowerCase(); diff --git a/index.html b/index.html index d6a0040f3..1155d620b 100644 --- a/index.html +++ b/index.html @@ -388,9 +388,16 @@ search(); }); - var query = window.location.hash.substring(1); - document.getElementById("search").value = query; - search(); + hashSearch(); + window.addEventListener('hashchange', function (evt) { + hashSearch(); + }); + + function hashSearch() { + var query = window.location.hash.substring(1); + document.getElementById("search").value = query; + search(); + } function search() { var searchTerm = searchField.value.toLowerCase(); diff --git a/src/footer.html b/src/footer.html index 6154d87c4..2fab83dfc 100644 --- a/src/footer.html +++ b/src/footer.html @@ -11,9 +11,16 @@ search(); }); - var query = window.location.hash.substring(1); - document.getElementById("search").value = query; - search(); + hashSearch(); + window.addEventListener('hashchange', function (evt) { + hashSearch(); + }); + + function hashSearch() { + var query = window.location.hash.substring(1); + document.getElementById("search").value = query; + search(); + } function search() { var searchTerm = searchField.value.toLowerCase();