Disable browser back button
Application Type


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() {

          window.history.pushState(null, "", document.URL);


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)


  history.pushState(null, document.title, location.href);


That should do the trick.

Kind Regards,

Hi João,

I have tried this also but facing same issue.

Hi Shrinjala, 

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.


António Pereira

Hi Shrinjala,

Good morning!

Might this post can help:


Kind regards,


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?


I have used the below Javascript

window.history.pushState(null, "", window.location.href);        

window.onpopstate = function(event) {

    window.history.pushState(null, "", window.location.href);

    var tl =  document.title;


    document.title= tl;


Please try if it can help you as well.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.