diff --git a/jquery.nav.js b/jquery.nav.js index 1296443..86fdb95 100644 --- a/jquery.nav.js +++ b/jquery.nav.js @@ -156,13 +156,26 @@ //Removing the auto-adjust on scroll self.unbindInterval(); + //Do we need to change the hash? + if(self.config.changeHash) { + // We need to insert a temp. link element to avoid breaking + // the broweser history. + var elem = document.getElementById(id); + var $a = $(' ').attr('id', id).css({ + position: 'absolute', + top: $(window).scrollTop(), + left: $(window).scrollLeft() + }); + + elem.id = ''; + $('body').prepend($a); + location.hash = newLoc; + $a.remove(); + elem.id = id; + } + //Scroll to the correct position self.scrollTo(newLoc, function() { - //Do we need to change the hash? - if(self.config.changeHash) { - window.location.hash = newLoc; - } - //Add the auto-adjust on scroll back in self.bindInterval(); @@ -220,4 +233,4 @@ }); }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document );