(function() { var elements = document.getElementsByTagName('a'), baseUri = window.location.href.slice(0, -window.location.hash.length), el, i, hashPos; for (i = 0; i < elements.length; ++i) { el = elements[i]; hashPos = el.href.indexOf('#'); if (hashPos !== -1) { el.href = baseUri + el.href.slice(hashPos); } } })();