From 4d4f6efeb8d036590b5b7584fe8b236ad0aba34e Mon Sep 17 00:00:00 2001 From: Robert Lord Date: Wed, 11 Jun 2014 22:10:31 -0700 Subject: [PATCH] Fix #75, don't set page hash to undefined --- source/javascripts/lib/jquery.tocify.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/javascripts/lib/jquery.tocify.js b/source/javascripts/lib/jquery.tocify.js index d122048..d32ad7b 100644 --- a/source/javascripts/lib/jquery.tocify.js +++ b/source/javascripts/lib/jquery.tocify.js @@ -722,12 +722,14 @@ if(self.options.scrollHistory) { - if(window.location.hash !== "#" + anchorText) { + // IF STATEMENT ADDED BY ROBERT - if(history.replaceState) { + if(window.location.hash !== "#" + anchorText && anchorText !== undefined) { + + if(history.replaceState) { history.replaceState({}, "", "#" + anchorText); // provide a fallback - } else { + } else { scrollV = document.body.scrollTop; scrollH = document.body.scrollLeft; location.hash = "#" + anchorText;