In web design, it may be necessary to prohibit the browser's back button due to certain requirements, especially for some websites that are more strict with user operations. If the user repeatedly submits events and then backs back, this may cause catastrophic problems for some data. So today I will introduce to you a method to prohibit the browser's back button through location.replace.
The principle of this method is to replace the current historical record with the URL of the new page, so that there is only one page in the browsing history, the back button is always in an invalid state, and the user cannot back down. The specific usage method is as follows:
①For example, now I want to make a hyperlink, which links to the page htmer.htm, and the code is as follows:
<a href="#" onclick="location.replace('htmer.htm')">Link</a>② If you use buttons for hyperlinking, the code that also links to the page htmer.htm is as follows:
<input type="button" value="Submit" onclick="location.replace('htmer.htm')">