Disable browser back button?

Gaurav Kumar15
Giga Guru

Hi All,

How to disable the Browser Back button in Service Now, based on URL.

Did anyone worked on this. Any help will be greatly appreciated.

Regards,

Gaurav

4 REPLIES 4

Atul Kumar2
Giga Guru

Hi Gaurav,



I believe that there is not any such settings since it is specific to the browser.



Can you check in the browser setting from where you can disable the back forward functionality if it is available.



Regards,


Atul Kumar


Brad Tilton
ServiceNow Employee
ServiceNow Employee

There isn't really a ServiceNow option to do this. There are some different javascript options if you search the web, but none of them are great. What is the problem you're trying to solve by disabling the back button?


Hi Brad,



Actually we want that once the users place an request from Service Catalog via portal, then after the order they should not be able to go back, so we wanted to restrict this back button feature of browser.



I checked various javascript options but nothing seemed to work



Regards,
Gaurav


Amit104
Kilo Expert

I know this post is very old but I have a working solution for this. 

I saw this code some where in the community and it worked for me.

Write this in your client controller (history contains your browser history)

history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};