Prevent page refresh?

Hello,
Is it possible to use code to prevent a user using page refresh?
Reason - to prevent overwrite of getItem values.

It would be OK for the user to close the tab - but it would be helpful to prevent tab/page refresh

Any suggestions gratefully received
Thanks

Maybe you can do it with custom code on some browsers.
But you should not.
It’s bad behavior and the user should always have control over the browser.
You can prompt alert before refreshing though:
.
Why do you need that?

Thanks for your response.
A new tab opens using getItems values generated from input data by users. Each time the users changes the input & getItem values change, a new tab opens.
The problem is, if they refresh any of the tabs (in error) the data is overwritten with the latest getItem values resulting in incorrect data for that tab.
At the end of their online session they close all of the tabs.
Is there a way of running the getItems function only once for each new tab & saving the data as constant values?

You can store the selected info (in session storage or URL query parameters)and bind it to the input elements on refresh.
See storage session Or query params
Either of them should work .