How to scroll to a desired part of a page using query parameters

0
Hello.The feature I want is to navigate to a specific part of a page using query parameters. How can I implement this?
asked
2 answers
2

You can use a nanoflow on page load and call the ScrollTo action from the Web Actions module. This lets you scroll to a specific element.


If you are using query parameters, you can read the value and add a simple decision in the nanoflow. Based on that value, you trigger ScrollTo for the related section on the page.


You can also use SetFocus if you want to move the focus to an input or element, for example, in forms.


Just make sure the target element is already visible on the page when the nanoflow runs. If it is loaded later, the scroll may not work on the first try.


If this resolves your issue, kindly mark it as accepted.


answered
1

Hey

You can achieve this by using query parameters along with a small JavaScript action in Mendix. Basically, when you navigate to a page, you pass a value in the URL like


/p/home?section=unassigned.


On page load, you read this value using a JavaScript action (by getting it from window.location.search) and store it in a variable or helper object. Once you have the value, you can use it to decide where to scroll on the page.


For example, if the section is “unassigned”, you can trigger a simple JavaScript like scrollIntoView() on the container that has the matching ID (e.g., unassignedSection). Just make sure your target container has the correct ID set.


This way, whenever the page opens, it automatically scrolls to the desired section based on the URL, giving a smooth and user-friendly experience.


Thanks!

answered