开发者

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

开发者 https://www.devze.com 2022-12-19 15:18 出处:网络
Having an odd problem at the site. Link tag having href=\"#anything\" doesn\'t move you to the top of the page or to the specified anchor, it moves you to the home page. That\'s it - when I hover over

Having an odd problem at the site. Link tag having href="#anything" doesn't move you to the top of the page or to the specified anchor, it moves you to the home page. That's it - when I hover over the link I see at my FF's status bar example.com/# instead of example.com/test开发者_StackOverflow中文版page.php#.

Site is full of crap code and it's impossible to verify all of the settings and especially header configuration or etc.

Any hints on where this might be?

P.S. Link's href is not altered with JS, Firebug claims it to be href="#" when I click it.


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:

  • http://w3schools.com/tags/tag_base.asp
0

精彩评论

暂无评论...
验证码 换一张
取 消