We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38310
    • 23 Posts
    Like this page, its url is www.example.com/examplepage.html :
    ....
    <div id="top">
    .....
    .....
    <a href="#top">Jump to the top of the page</a>
    ....
    


    when I click the link it redirect to the www.example.com#top, not jump to the top area in the current page: www.example.com/examplepage.html#top.


      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You need to explicitly specify the entire URL
      <a href="[[~[[*id]]]]#top">Jump to the top of the page</a>
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 38310
        • 23 Posts
        Quote from: sottwell at Nov 30, 2012, 09:49 PM
        You need to explicitly specify the entire URL
        <a href="[[~[[*id]]]]#top">Jump to the top of the page</a>
        Yes, set the entire URL can make it work.

        But if when the anchor link self get by the ajax, it will just generate html like this: <a href="[~[*id*]~]#top">Jump to the top of the page</a>, the modx placeholder [~[*id*]~] won't change.

        I think there maybe some other way to simulate the effect use Javascript.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah. No, something that is done by javascript in the browser won't work, since the tags have to be processed by MODx on the server. If the link is generated by Javascript, you'll have to use whatever Javascript does to output the current page's URL, such as window.location.href or document.URL
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 38310
            • 23 Posts
            Quote from: sottwell at Nov 30, 2012, 10:16 PM
            Ah. No, something that is done by javascript in the browser won't work, since the tags have to be processed by MODx on the server. If the link is generated by Javascript, you'll have to use whatever Javascript does to output the current page's URL, such as window.location.href or document.URL
            Your analysis is very clear, for my situation, I will select the Javascript way to do this now.