Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

href

anchor

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.

like image 984
Brock Avatar asked Feb 10 '10 16:02

Brock


People also ask

What is href in HTML?

The href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink.

What is href in URL?

The href attribute link (short for “Hypertext REFerence”) indicates the relationship between pages to search engines. href is an attribute of the anchor tag and contains two components: The URL (the actual link) and. The clickable text or object that users will see on the page (known as the “anchor text”)

Is href a tag in HTML?

The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link's destination. By default, links will appear as follows in all browsers: An unvisited link is underlined and blue.


1 Answers

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.

like image 162
Sampson Avatar answered Nov 19 '22 07:11

Sampson