Scrolling to top of page on reload after "Next" button click

Prevent page from scrolling to top after navigating a multipage form.

Overview

The page automatically scrolls to the top after each "Next" or "Prev" button click, forcing users to manually scroll back down.
Add a JavaScript event listener to smoothly scroll the page back to the form's position after the new page loads.

Answered
ChronoForms v7
am amitycol 21 Sep, 2023
I'm trying to work out a way to overcome page auto-scrolling to the top after every click on Next/Prev buttons of a multipage form. Forces the user to have to scroll down to the bottom of the page where the form is loaded after each navigation click (if they can decipher what has happened). I thought the loading of pages would be by jquery.
Max_admin Max_admin 27 Sep, 2023
Answer
you can add the following JS code in a JS view to your "next" page:

document.addEventListener("DOMContentLoaded", function (event) {
	window.scrollTo({
			top: document.querySelector(".chronoform").getBoundingClientRect().top,
			behavior: "smooth"
		});
})

this code is for v7 and can be improved if you use v8 because there is a core function for that
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.