Make anchor links refer to the current page when using <base>

后端 未结 12 1198
情书的邮戳
情书的邮戳 2020-11-30 03:29

When I use the html tag to define a base URL for all relative links on a page, anchor links also refer directly to the base URL. Is there a way to

12条回答
  •  孤街浪徒
    2020-11-30 03:58

    From the example given in the question. To achieve desired behavior, I do not see the need of using "base" tag at all.

    The page is at http://example.com/foo/

    Below code will give the desired behaviour:

    bar 
    baz 
    

    The trick is to use "/" at the beginning of string href="/bar/".

提交回复
热议问题