Anchor element not working in firefox and chrome

前端 未结 13 951
甜味超标
甜味超标 2020-12-20 17:36

I have a hyperlink on an image on my client site. It\'s working in IE but when I open the same page in Chrome/Mozilla it\'s not showing the anchor pointer and nothing happen

相关标签:
13条回答
  • 2020-12-20 18:20

    I experienced a similar problem in Chrome where my cursor did not change to a pointing hand when hovered over my navigation links, and the links themselves were unresponsive when clicked on. By adding the z-index property with a value of 999 to my anchor element in my style sheet, the expected behavior returned.

    0 讨论(0)
  • 2020-12-20 18:23

    Without the full HTML source code, I'll point to that this anchor is nested or after to some element that doesn't have a closing tag.

    Post full HTML source code if this isn't the problem.

    You can find this problem easly by validating your document with:

    • http://validator.w3.org/

    It's the W3C official HTML/XHTML validator, so if some element isn't closed, it'll point which one you need to correct!

    EDIT: After watching your HTML source code posted in answer's comments... where's the document type (DOCTYPE) declaration? You forgot to add it!

    Add this at the beginning of your HTML document:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    

    When you don't provide a document type, browsers render web pages in "quircks" mode, which is a compatibility mode that may not render your page as you expected. Learn more about that here:

    • http://en.wikipedia.org/wiki/Quirks_mode

    Let me know if this solves your problem!

    0 讨论(0)
  • 2020-12-20 18:25

    Simple Work around: This works in all browsers I have tested so far use document.getElementById([anchor tag]).scrollToView(true);

    Example: --from--

    <a href="#" onclick="document.getElementById('ShowMeHow2').scrollIntoView(true);return false;">
    

    --to--

    <a id="ShowMeHow2" name="ShowMeHow2"> </a>
    
    0 讨论(0)
  • 2020-12-20 18:25

    Check to see if you are using css z-order at all in the page. Incorrect z-orders can cause buttons and links to not work.

    0 讨论(0)
  • 2020-12-20 18:25

    I am facing the same issue. This suggestion (adding position: relative to the containing div) seems to adress it, but I am doing absolute positioning and need to work around this in another way. I figured it might help someone else, though.

    0 讨论(0)
  • 2020-12-20 18:27

    I've spent the last few hours with this problem, in page anchor tags working in firefox and IE but not chrome. I'm not a professional developer, so I don't know why, but it seems that in some cases chrome doesn't read a tags from inside stacked divs and deliver you to a desired place on the same page. I got round it by adding a span id after my a id... - so it looks like this:

    <a href="#ID_NAME"></a>
    ...
    <a id="ID_NAME><a/><span id="ID_NAME"></span>
    

    Tested in Firefox, Chrome and Safari. Don't have IE on this machine to test though.

    0 讨论(0)
提交回复
热议问题