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

有些话、适合烂在心里 提交于 2019-12-01 03:32:52

My initial thought is that you may have a base tag in play somewhere. Check your code for something like the following, and remove it if necessary:

<base href="http://www.mydomain.com/testpage.php" />

Obviously, caution is necessary as there may be some markup that is dependent upon any pre-existing base tags. Also make sure that your href value is not preceded with a foward slash like this:

<a href="/#anything">Click Me</a>

As this will go to #anything on the default startpage of the root directory.

Do you perhaps have an <base> tag in the <head> section of your code?

That will make all relative url requests start with the specified href in the base tag. If the page relies on it's presence, I'd strongly discourage you from remove it or you might be in for a lot of updating.

More info:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!