Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I noticed that after the ajax page load, it does not scroll to the top of the page. Is there a particular reason?
I added three lines to ajax_pages.js file, to go back to the top, if no anchor.
Are you okay with that?
Here is the patch..
Comment | File | Size | Author |
---|---|---|---|
scroll_top_of_page_after_ajax_load.patch | 532 bytes | OwilliwO |
Comments
Comment #1
jamix CreditAttribution: jamix commentedI think it's a great idea, thanks. How about making it an option (i.e. checkbox) on the module settings page?
Comment #2
q00q00 CreditAttribution: q00q00 commentedGreat idea, but how to preserve a scroll position on history back?
Comment #3
T.Mardi CreditAttribution: T.Mardi commentedThanks for the patch, it works great! Is there a way to make the scroll to top any smoother?
Comment #4
wsjnorway CreditAttribution: wsjnorway commentedWhere do i put the patch?
I have been looking for a way to make the page reload scroll to top and this seems to work, but after i put in the file using notepad++ the module stops work and pages load normally and not using ajax.
Edit: Sorry for the grammatical errors. I think i know where to insert the code, however the problem remains.
Either clicking on a link takes you to the top of the next page without using the module, or the module works but you always end up "scrolled down to the bottom" on the page you are loading.
It seems like this fix disables the whole module.
Comment #5
T.Mardi CreditAttribution: T.Mardi commentedDid you insert the 3 lines of code into the ajax_pages.js file inside the module folder? You will need to remove the '+' before each line.
Here's a guide on how to apply patches manually
Remember to flush caches after you change a template or module file.