html – link not working

html – link not working

Every href needs a corresponding anchor, whose name or id attribute must match the href (without the # sign). E.g.,

<a href=#map>Map</a>

<a name=map>[content]</a>

An enclosing div is not necessary, if not used for other purposes.

Wow, thanks for pointing that out OP. Apparently Mozilla Firefox doesnt associate the id attribute with a location in the HTML Document for elements other than <a> but uses the name attribute instead, and Google Chrome does exactly the opposite. The most cross-browser proof solution would be to either:

1.Give your anchor divs both a name and an id to ensure max. browser compatibility, like:

<a href=#map>Go to Map</a> <!-- Link -->
<div id=map name=map></div> <!-- actual anchor -->


2.Only use <a> tags with the name attribute as anchors.

This will allow the on-page links to work in all browsers.

html – link not working

what happened with me is that the href does not work second time and that because I should Remove hash value first,,

take look how I resolved it

<a href=#1 onclick=resetHref();>go to Content 1</a>

function resetHref() {
    location.hash = ;

Leave a Reply

Your email address will not be published.