diff --git a/doc/activebookmark.js b/doc/activebookmark.js
index 88c879cf422cf4597dfba96a6d73cbca7507358d..407282d02ccde63611e66bff550b52ea51abfdc5 100644
--- a/doc/activebookmark.js
+++ b/doc/activebookmark.js
@@ -3,6 +3,7 @@ document.createElement("section");
 document.createElement("article");
 
 (function() {
+  if (!window.addEventListener) return;
   var pending = false, prevVal = null;
 
   function updateSoon() {
@@ -41,8 +42,16 @@ document.createElement("article");
     }
   }
 
-  if (window.addEventListener) {
-    window.addEventListener("scroll", updateSoon);
-    window.addEventListener("load", updateSoon);
-  }
+  window.addEventListener("scroll", updateSoon);
+  window.addEventListener("load", updateSoon);
+  window.addEventListener("hashchange", function() {
+    setTimeout(function() {
+      var hash = document.location.hash, found = null, m;
+      var marks = document.getElementById("nav").getElementsByTagName("a");
+      for (var i = 0; i < marks.length; i++)
+        if ((m = marks[i].href.match(/(#.*)/)) && m[1] == hash) { found = i; break; }
+      if (found != null) for (var i = 0; i < marks.length; i++)
+        marks[i].className = i == found ? "active" : "";
+    }, 300);
+  });
 })();