We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39085
    • 22 Posts
    I have a link at the top of my page in MODX 2.1.5

    <p><a href="[[~[[*id]]]]#registration">Register product</a></p>

    And way down the page I have the anchor

    <a name="registration"></a>

    But it won't work. Even if I place a link on another page specifying to go to the anchor, it doesn't work. Any ideas would be great. Thanks.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You don't need to use <a name="registration"></a>; any element with the same ID will also work <div id="registration"></div>.

      If you have a name attribute and also another element with an ID attribute with the same value - a form, for example, with id="registration" - then it won't work.
        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
        • 39085
        • 22 Posts
        Quote from: sottwell at Dec 05, 2012, 06:25 PM
        You don't need to use <a name="registration"></a>; any element with the same ID will also work <div id="registration"></div>.

        If you have a name attribute and also another element with an ID attribute with the same value - a form, for example, with id="registration" - then it won't work.

        I changed my link to....
        <p><a href="[[~[[*id]]]]#registration_page">Register product</a></p>

        And my "anchor" to be a div. There is no other id="registration_page" on the entire site.
        <div id="registration_page"></div>

        Still not working. If I have the syntax correct, could it be something else altogether?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Must be; I tried it on a page with and it worked just fine. I seem to vaguely remember something about certain browsers and a very long page not working, but I'm not finding anything about that now.

          Can you give a URL to look at the real thing?
            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I did find something about IE not working correctly (big surprise) if the anchor had no text, it needed at least a non-breaking space.
              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
              • 39085
              • 22 Posts
              It doesn't work in any browser. I only have a local copy I'm working on. I'm wondering if there is a setting preventing it from working? Thanks for your help though. I never thought something as simple as an anchor would cost me so much time.
                • 6038
                • 228 Posts
                copy and paste the source here or pastebin so we can look
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Very strange. I pasted the two lines you posted, put a bunch of nonsense between, and it worked fine. There must be something on the page keeping it from working properly. That's why I wanted to see the whole page.

                  Have you pasted the entire page's HTML into the w3c validator?
                    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
                    • 39085
                    • 22 Posts
                    Thank you everyone! You were all instrumental in leading me in the right direction. I'll try to explain. I had my page creating two small sections for two different purposes. Then I'd hide the section that wasn't currently in use using CSS and show the other section, and vice versa. So, in essence they were both using similar chunks and TVs. And. Voila, one of them was an ID and hence had the same name. Yet again it was my mistake and not a MODX issue. And I've learned a lesson.

                    THANKS!!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      That's what we're here for wink

                      Would you please mark this "answered"?
                        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