Hi
I’m trying to disable or unutilized the browser back button, so that the user may not go back, I have tried the following JS code.
window.history.pushState(null, "", document.URL);
window.onpopstate = function() {
};
After clicking on back button user can not go back to previous page but browser title is changing for previous page, how to solve this please help.
Hi Shrinjala,
Try the following JS:
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event)
{
});
That should do the trick.
Kind Regards,João
Hi João,
I have tried this also but facing same issue.
Check the Navigation JavaScript API made available by the OutSystems Platform. There you will find the "registerBackNavigationHandler" function to manage the back button. Check if it fits your challenge.
P.S.: Allow me to challenge if you really need to control the back button? This is not a recommended behavior by many developers.
Cheers,
António Pereira
Good morning!
Might this post can help:
https://www.outsystems.com/forums/discussion/9789/transactional-apps-and-the-back-button/
Kind regards,
Chris
Thank you so much all for your response, issue is resolved,
can you help me to restrict user to go back
How did you do it?
Hello,
I have used the below Javascript
window.history.pushState(null, "", window.location.href);
window.onpopstate = function(event) {
var tl = document.title;
document.title="";
document.title= tl;
Please try if it can help you as well.
Thanks
hi may I know where did you implement it? Thank you
You should place the script in OnReady of the page. This works well
05/09/2023
VERY COOL :) TANKS :)
Hi,
I have used the below Javascript,
window.onpopstate = function (event) {
var originalTitle = document.title;
document.title = "";
document.title = originalTitle;
window.location.reload();
Suggestions:
- Use this code at javascript tool in OnReady Event action. (Don't use the javascript in any Client/Server actions or at Global scripts, use at OnReady event action.)
- If you want any condition according to which you want to restrict the browser you can do that before calling the javascript in OnReady action.
- This javascript will restrict the back button of the browser. Used window.location.reload() so that the page reloads.