Unexpected html anchor redirection

This question already has an answer here:

  • href=“#” redirects to the index page but not to the current page's top 2 answers

  • Thanks to @AmrElgarhy, I'll leave an answer to my own question here.

    It's because of the <base> element in my HTML code. For my solution I can't delete this node, but I'm going to add the request-uri to my "to-top"-anchor programmatically like this:

    <header id="top">top</header>
    <div style="height: 2000px"></div>
    <a href="{{ request.uri }}#top">Click me</a>
    

    Whereas {{ request.uri }} will contain /foo or similar.

    链接地址: http://www.djcxy.com/p/89016.html

    上一篇: 锚和编号工作以引用页面上的特定部分

    下一篇: 意外的html锚定重定向