Is it possible to change the position when I want to go back to the last page?

He I was wondering How do I stop my web page from scrolling to the top when I press the back button on top of my browser.

Example: If I press on a product on my online store and I want to go back, it automatic move to the top. I want the page to stay where I was.

Or it is possible to fix this problem with a button or something like that?

You can get the current position when the user clicks a product, and then when the user is back scroll to this position.
See: https://www.wix.com/corvid/reference/wix-window.html#getBoundingRect
and: https://www.wix.com/corvid/reference/wix-window.html#scrollTo

Thank you so much:)

@J. D He its me again. I was wondering if you could help me with this problem. I´m not really good with coding. Do you think you can explain how and where I’m gonna put the code? I have tried everything but I can’t understand how to do it. My email is: maxmorris0505@gmail.com

@maxmorris0505 , first of all you have to activate Corvid, if you haven’t done it so far:
https://support.wix.com/en/article/getting-started-with-corvid-by-wix
Then open the code panel:
https://support.wix.com/en/article/corvid-working-in-the-code-panel
See also the attached picture.
Then you should add an onClick() function to your product button:
https://support.wix.com/en/article/corvid-reacting-to-user-actions-using-events
In the function you can collect data about the current position.
and continue from here.

codePanel

Hello, I have tried above but could not achieve, I am trying to go back to same product position when I click back on the browser;

Please advise.

let scrollX = 0;
let scrollY = 0;

$w.onReady( function () {
$w.scrollTo(scrollX, scrollY);
});

export function gridGallery1_viewportLeave(event) {
//Add your code for this event here:
$w.getBoundingRect()
.then( (windowSizeInfo) => {
let windowHeight = windowSizeInfo.window.height; // 565
let windowWidth = windowSizeInfo.window.width; // 1269
let documentHeight = windowSizeInfo.document.height; // 780
let documentWidth = windowSizeInfo.document.width; // 1269
scrollX = windowSizeInfo.scroll.x; // 0
scrollY = windowSizeInfo.scroll.y; // 120
} );
}

If you’re leaving the page you have to store the position first.
If the user leaves the page on clicking then you should create an onClick listener, that will run the getBoundingRect() and store it to the memory or to the browser cache, see here how to store:
https://www.wix.com/corvid/reference/wix-storage.html

You also need to add to code that will scroll to this position when the user is back:
https://www.wix.com/corvid/reference/wix-window.html#scrollTo

Thanks JD. I am on a page where a gridgallery is located. There is no click event for the gridgallery so I used viewportLeave event to store the scrollx and scrolly values.

On the same page onReady event, I tried to scroll to the values retrieved but no luck.

Sorry I am new to Corvid and java scripting, hope you can assist.

import wixWindow from ‘wix-window’;
import {session} from ‘wix-storage’;

wixWindow.onReady( function () {
wixWindow.scrollTo(session.getItem(“PageScrollX”),session.getItem(“PageScrollY”));
});

export function gridGallery1_viewportLeave(event) {
wixWindow.getBoundingRect()
.then( (windowSizeInfo) => {
let windowHeight = windowSizeInfo.window.height; // 565
let windowWidth = windowSizeInfo.window.width; // 1269
let documentHeight = windowSizeInfo.document.height; // 780
let documentWidth = windowSizeInfo.document.width; // 1269
let scrollX = windowSizeInfo.scroll.x; // 0
let scrollY = windowSizeInfo.scroll.y; // 120
} );

session.setItem("PageScrollX", "scrollX"); 
session.setItem("PageScrollY", "scrollY"); 

}