Navigating between form pages

I need to create a button (or a link) on a form, which makes a user jump two pages back (e.g. from page 4 directly to page 2).

What would be the best approach to achieve this goal?

You dont need to create button. It is much easier, just add a visible codition on Page 3.

getValue("@visitedPages").substr(getValue("@visitedPages").lastIndexOf(",") + 1)==="Page4"	

Thanks, but I’m afraid this doesn’t really solve my problem.
I don’t need to hide Page 3, I only want to get BACK from page 4 to page 2.

Exacly. It will work.
visitedPages is Array of all pages you have seen.

when u are on Page2
visitedPages =["Page1","Page2"]
or
visitedPages =["Page1","Page2","Page3","Page4","Page2"]
but on Page4
visitedPages =["Page1","Page2","Page3","Page4"]

Sir, I’m afraid we are not on the same page.

Again, what I need is a button or a link on Page 4, which lets a user return to Page 2 but only when he/she decides to jump back to Page 2.

I think the trick you provided just hides Page 3 when user has reached Page 4, which makes it impossible to get back to Page 3 in a regular way - by using the “Back” button.

You are right!
In this point of view is much easier, use PageNavigationLink and set name of target page
Example from car insurance process.

… and this is exactly what I was looking for, thanks!