简体   繁体   中英

Can I use relative <a href=#foo> and go to a named anchor on the current page when when <base> is being used?

If I have a page www.example1.com/foo/test.html as follows:

<head>
<base href=http://www.example2.com/>
</head>
<body>
<a href=#foo>foo</a>
...
<a name=foo />
</body>

Then when I click "foo" it takes me to http://www.example2.com/#foo instead of the current page's foo. I suppose this sort of makes sense, but is there a way to do a page-local named anchor jump when <base> points somewhere else?

Note that test.html is named named dynamically, so an absolute path in the href=...#foo isn't an option. Some JS could be, but strait html would be preferred.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM