1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Problem with Anchor links

Discussion in 'XenForo Questions and Support' started by AGPR, Dec 18, 2015.

  1. AGPR

    AGPR New Member

    Hi,

    Im facing a problem with anchor links in pages.

    I have created a page with this content:

    <a href="http://www.blabla.com/pages/test/#test">TEST123</a>
    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />


    <a name="test" id="test">q</a>
    CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT
    Now when i click on the anchor link, it will just scroll a few pixels and stop there. If i select the URL on the addressbar and click enter it works fine.

    Any ideas what could be the problem? That html code outside xenforo works fine. Im not sure where the problem lies.

    Any help appreciated. Thanks in advance.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    When scrolling to an anchor the browser will scroll down until the anchor element is at the top of the page unless there is not enough vertical height to the page in which case it will simply scroll to the bottom of the page because it can't scroll any lower.

    I think this might be what you are describing.
     
  3. AGPR

    AGPR New Member

    Hi,

    Thanks for your reply.

    Unfortunately thats not the case. The "CONTENT CONTENT CONTENT C....." part of the code i posted is not visible on my screen when the page loads.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Can you post a link to that page node so I can test it?
     
  5. AGPR

    AGPR New Member

    Thanks for your reply.

    Unfortunately its on localhost. Would any HTML code of the page help if i posted?
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I really need to access the actual page. The html source might not be good enough if this is some kind of rendering or styling issue.
     
  7. AGPR

    AGPR New Member

    I think that it may have something to do with the links.

    if i put
    <a href="#test">TEST123</a>​

    it will redirect me to the homepage (http://www.blabla.com/)

    if i put
    it will scroll just a few pixels.

    However, if i put this:
    in a local file and run it on my computer, it works fine. So this means if the URL is loaded externally it works.

    So i assume it has something to do with the site paths and configuration?

    Thanks in advance
     
    Last edited: Dec 21, 2015
  8. Mike

    Mike XenForo Developer Staff Member

    Before the #, put the following instead of the full URL:
    Code:
    {$requestPaths.requestUri}
    Because of the base tag, this is required to ensure the links are correct.

    That said, the browser is the one doing the scrolling if it's staying on the page, so we would need to see it happen in place to really make any other suggestions.
     
    rickhz likes this.
  9. AGPR

    AGPR New Member

    Thanks for your reply Mike.

    Now it works but it will first refresh the page and then go to the anchor link.
     
  10. Mike

    Mike XenForo Developer Staff Member

    That shouldn't really be happening -- it's how the "go to top" link works on every page.
     

Share This Page