Force Reload Without Confirmation

Wasdom_Kung
Tera Guru

Hello!

 

 


I have created a client script that when an item is submitted/added to cart, will reload the current page, however I noticed that the browser will had a reload/cancel popup.

 

Is there a way to force this refresh without input from a user?

 

This is using the following line: 

location.reload(true);

 

5 REPLIES 5

Simon Christens
Kilo Sage

Hi,

You can add: g_form.modified = false; before you reload - then it tells the browser that no new inputs is present

I used this but still got the "Changes that you made may not be saved." popup from the browser. 

I used the following

function onSubmit() {
    //Type appropriate comment here, and begin script below
	g_form.modified = false;
    location.reload();
}

Hi @Wasdom_Kung ,

 

You forgot to add return false.

function onSubmit() {
    //Type appropriate comment here, and begin script below
	g_form.modified = false;
    location.reload();
return false;
}

 

I tried it in my PDI its working as expected.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

I've tested this in Chrome and Opera but still the same popup occurring, I've added your proposed fix as well, but the popup still needs to be clicked before it submits

Wasdom_Kung_0-1732795688031.png