Force Reload Without Confirmation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 02:49 AM - edited 11-28-2024 02:50 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 03:01 AM
Hi,
You can add: g_form.modified = false; before you reload - then it tells the browser that no new inputs is present
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 03:58 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 04:03 AM
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
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 04:08 AM
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