Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

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

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/testpage.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...