WordPress.org

Forums

[resolved] Anchor Link To An Anchor Tag On Another Page Does Not Work (15 posts)

  1. Jessica
    Member
    Posted 1 year ago #

    Information:
    Self Hosted WordPress Site
    Testing on local host using Uniserver as well as the Test site and pre-production site hosted on the company's local servers rather than FTP.
    Issue

    • Created several Anchor Tags on one page
    • Linked to said Anchor Tags via a list on another page.

    Anchor Link Code:

    `<a id="anchorlink1"></a>
    <a href="http://fullurlhere/nbs-test-panel-of-diseases-2#anchorlink1">link text</a>`

    I also tried:

    ` <a name="anchorlink1"></a>
    <a href="http://fullurlhere/nbs-test-panel-of-diseases-2#anchorlink1">link text</a>`

    Result:
    When a user clicks the link to the Anchor Link on a different page, the address bar will display the full url with the Anchor Link for a second then the Anchor Link will be removed and only the root URL to the page will be displayed.

    Example:
    Displays for a second:

    http://fullurlhere/nbs-test-panel-of-diseases-2#anchorlink1

    Then it will revert to this:

    http://fullurlhere/nbs-test-panel-of-diseases-2

    Troubleshooting:
    I have done the following trouble shooting all with no effect:

    • Commented out this code in the .httaccess file: RewriteBase /
    • Updated the Settings/Permalinks to remove the /
    • Installed the TinyMCE Plugin that inserts Anchor Tags to make sure that I was adding the correctly.
    • Tried ID rather than Name
    • Moved the Anchor Tag from the inside the H4 tag to outside of it, before and after and in front of the paragraph and outside to see if that would have an effect. (it did not)
    • Tried linking from inside the page, rather than to the page. This worked like it should.
    • Copy and pasted the full URL into the address bar. That worked too.

    It appears that this issue only happens when I link to the Anchor Tag from a different page.

    Any help would be greatly appreciated.

  2. kmessinger
    Forum Moderator
    Posted 1 year ago #

    If you want a link to jump a specific location on a different page, you'll need to replace #anchor with the full URL for the page, similar to:
    Link Text - See more at: http://help.typepad.com/anchor-tags.html#sthash.RWtT4d5y.dpuf

  3. Jessica
    Member
    Posted 1 year ago #

    Hi kmessinger, thank you for responding. I may have misunderstood however. When I link from a different page I do use the full URL: http://fullurlhere/nbs-test-panel-of-diseases-2#anchorlink1

  4. kmessinger
    Forum Moderator
    Posted 1 year ago #

    I googled it (as you did) - saw your entry. I don't know but I am still on my first cup of coffee. I found one that said use <a name="anchor" id="anchor"></a> instead on <a id="anchorlink1"></a> but I don't know if it works.

  5. Jessica
    Member
    Posted 1 year ago #

    Unfortunately that does not work either. The same thing happens where the full url will display for a second and it will jump to the anchored text, but then the #and everything after is removed from the url and it jumps back to the top.

  6. kmessinger
    Forum Moderator
    Posted 1 year ago #

    http://www.site.com/go-anchor-page/ and hit test will take you to http://www.site.com/test-anchor/

    First page <a href="http://www.site.com/test-anchor/"> test</a>

    Second page <a name="anchor" id="anchor">

    I will remove these links after a while. Must be the #

    [edited]

  7. Jessica
    Member
    Posted 1 year ago #

    Thanks for this, however, this appears to be linking to another page:

    <a href="http://www.ourexcellentadventures.com/test-anchor/"> test</a>

    Rather than linking to an anchor tag with in the page.

    I am so stumped. It was suggested that it might be a server setting issue. It is simply the strangest thing and I really wish i could find a solution.

    It is only when linking from another page.

  8. kmessinger
    Forum Moderator
    Posted 1 year ago #

    This seems to work for me.
    http://www.ourexcellentadventures.com/page-anchor-test/#pageofjunk

    I think you are missing a /

  9. Jessica
    Member
    Posted 1 year ago #

    I have tried it with that as well and it still does the same thing.

  10. kmessinger
    Forum Moderator
    Posted 1 year ago #

    Have you tried with the default theme and no plugins?

  11. Jessica
    Member
    Posted 1 year ago #

    That was a great suggestion and I am kicking myself for not thinking of it. I had previously deactivated all of the plugins but had not tried a default theme.

    I just did and the issue was not there so there must be something going on with the code that is causing this and I am thinking it may be javascript or jquery.

    Just need to narrow down the cause.

  12. Jessica
    Member
    Posted 1 year ago #

    Ok so I narrowed it down to the jquery.jstree.js file. I of course have no idea how to fix it.

  13. Jessica
    Member
    Posted 1 year ago #

    So, We discovered that the issue was a specific code in the js file. There were six instances in it and once we removed them everything worked fine.

    .replace(/^#/,"")

  14. jokint
    Member
    Posted 1 year ago #

    I have the same problem in http://www.ismaelserrano.es/prueba-letra/ can you explain me the solution ? Thanks

  15. Jessica
    Member
    Posted 1 year ago #

    Hi jokint, I talked about what we tried above, however, what we ended up doing is using a different menu.

Topic Closed

This topic has been closed to new replies.

About this Topic