[scripts] fix anchor links not working

This commit is contained in:
Dmytro Meleshko 2020-08-12 22:55:54 +03:00
parent 3a02a30ef3
commit d67637769d

View file

@ -141,6 +141,19 @@ rendered_html = """\
</div> </div>
<div id="footer" role="contentinfo"></div> <div id="footer" role="contentinfo"></div>
<script>(function(){{
var anchorHrefPrefix = window.location.href.replace(/#.+$/, "")
var links = document.getElementsByTagName("a")
for (var i = 0, len = links.length; i < len; i++) {{
var link = links[i]
var href = link.getAttribute("href")
if (typeof href === "string" && href[0] === "#") {{
link.setAttribute("href", anchorHrefPrefix + href)
}}
}}
}}())</script>
</body> </body>
</html> </html>