How to handle chrome reload

Hi,

Is there a way to manage the navigation icons and refresh icon in Chrome? When I click on them, the values on the pages appear incorrect. Is there any session or gateway event that can address this issue?
image
Thanks in advance

Half the concept of javascript security and usability require there to be no way for a malicious script to disable or remove functionality like these buttons.
As a result, short of recording the use of the buttons and trying to minimise the detrimental effects on sessions, I am not sure you will have much luck.

If you can elaborate on situations where values become incorrect, it would help us diagnose and suggest possible solutions.

I have a screen (e.g., url:/xyz), and when the user clicks on it, they navigate to another view (View 2) where a back button is provided. In this scenario, the user should enter some data before going back, and this is handled by the back button where the data is saved.

However, I'm concerned about what happens if the user refreshes the page or clicks the browser's back/forward buttons. How can I handle this situation?

You cannot prevent the user from leaving the page.

You could however in an OnShutdown Event in your components, try to deteect if everything was filled in or not. And than have some sort of popup open in your project where they have to fill in all the missing data...

This probably wont catch everything though

Why not provide your own back button to try to avoid the user using the browser buttons? You'll never stop them from using them unless you make them use the perspective apps.

being forced to do something when leaving is kinda weird, but idk the situation

We have already provided a back button, but what if he clicks <- in chrome.

No way to control that besides making them use perspective workstation.

Why does the user need to provide data when going back to the previous page ?

Thats the logic expected by user.
My only doubt here is, do we have any options in ignition to handle reload like we have startup/shutdown events?

Browsers block almost all interference with reloads and navigates.
As this is a security hazard.

If you give more details about why and what your users need to do before leaving, maybe there is a way to achieve this nonetheless with the limited functions there are.

I often get confronted with an "Are you sure you want to leave" popup on many sites when I attempt to navigate away from an unfinished form.

How is that done? Something like that would solve the problem here.

Beyond that, I imagine a simple label advising the user against using the browser's nav buttons would be helpful.

1 Like

Yes that would ask a confirm button, but they can still always leave.
Also not sure if it would work with react routing for navigation, but it should work with reload.

Something like this probably? in a binding on markdown component where escape html is off. (untested)

	code =  """<img style='display:none' src='/favicon.ico' onload=\"
		const beforeUnloadHandler = (event) => {
			event.preventDefault();
			event.returnValue = true;
		};
  		if ("""+value+""") {
			window.addEventListener('beforeunload', beforeUnloadHandler);
		} else {
			window.removeEventListener('beforeunload', beforeUnloadHandler);
		}
	\"></img>""".replace("\n", "").replace("\t", "")
	return code

There are serveral issues with this though...

  • Does not work on all browsers,
  • Only shows a default message,
  • Might stay attached to the whole session, if binding didnt get to remove the event. (reload should fix probably),
  • Might not work with persective navigate
2 Likes

You might find my pageVarMap() functions useful for such cases (from my Integration Toolkit).

What if you renamed your back button to "Save" so that the user realizes they must click that button for the values to be saved, and it just happens to also go back to the previous page.

How to import the integration toolkit to my project?

  1. Download the .modl file.
  2. Gateway | Config | SYSTEM | Modules | Install or Upgrade a Module ...

Download (at bottom of page):
https://www.automation-pros.com/modulesales.html

Documentation:
https://www.automation-pros.com/toolkit/doc/

2 Likes

I dont see download option in below link,
https://www.automation-pros.com/toolkit/doc/index.html#reflection
Could u please guide me?

Read my post again.

Got it.

1 Like