We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28475
    • 28 Posts
    Every time I browse to my website, it shows up scrolled a bit down. When I visit different parts of the site, the pages load also scrolled a ways down. What causes this? Is it possible to make all pages load at the very top (at the site header)?

    Thanks.
      • 16702 ☆ A M B ☆
      • 536 Posts
      can you give web-site address smiley
        palma non sine pulvere
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Do you by any chance have a form somewhere in the page? If so, are any of the form fields given a focus? If they do, the page will auto-scroll to focus on that form field.
          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
          • 28475
          • 28 Posts
          Website address is http://saskatoonsailing.ca/
          I don’t have any forms.. well I do on some pages, but on the pages that I don’t, the issue still exists.
            • 16702 ☆ A M B ☆
            • 536 Posts
            Quote from: stenzor at Jul 02, 2010, 02:47 AM

            Website address is http://saskatoonsailing.ca/
            I don’t have any forms.. well I do on some pages, but on the pages that I don’t, the issue still exists.

            i thing is work nice...can you show exactly where is problem smiley)))

            CHeers
              palma non sine pulvere
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Yes, you do. You have the login form in the sidebar. The login form specifies that the first field gets the focus. So depending on screen size and resolution, if that form field falls below the bottom of the screen, the page will scroll down to expose the form field. You’ll notice the blinking cursor is already in that field.

              At the bottom of the page:
              <script type="text/javascript">
                      if (document.loginfrm) document.loginfrm.username.focus();
                  </script>
              
                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
                • 28475
                • 28 Posts
                Oh crap, I completely forgot about that! Thanks!
                I removed the entire chunk of code:
                <script type="text/javascript">
                if (document.loginfrm) <?php echo !empty($uid) ? "document.loginfrm.password.focus()" : "document.loginfrm.username.focus()" ?>;
                </script>
                

                And it seems to be working nicely. I don’t know much about javascript, but it doesn’t look like removing that code hindered any other functionality. Correct me if I’m wrong though...
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  No, it won’t hurt anything. All it does is force the focus to the username field, which is what’s causing the page to scroll.
                    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