It is possible to change the state of the URL with HTML5 history, without triggering the browser to follow the new state. This is not supported by all browsers.
Using history.replaceState()
has the additional benefit that when the user uses the back button of the browser it will not just scroll up first.
$(window).on('activate.bs.scrollspy', function (e) {
history.replaceState({}, "", $("a[href^='#']", e.target).attr("href"));
});