Home >Web Front-end >JS Tutorial >Disable browser backing to prevent repeated submissions through location.replace_javascript tips

Disable browser backing to prevent repeated submissions through location.replace_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:37:121351browse

In web design, it may be necessary to disable the browser's back button due to certain needs, especially for some websites that are strict on user operations. If the user repeatedly submits events and then backs off, this may affect some data. create catastrophic problems. So today I will introduce to you a method to disable the browser back button through location.replace.

The principle of this method is to replace the current history record with the URL of the new page, so that there is only one page in the browsing history, the back button is always inactive, and the user cannot go back. The specific usage is as follows:

①For example, now I want to make a hyperlink. This link links to the page htmer.htm. The code is as follows:

<a href="#" onclick="location.replace('htmer.htm')">链接</a>

② If a button is used for hyperlinking, the code that also links to the page htmer.htm is as follows:

<input type="button" value="提交" onclick="location.replace('htmer.htm')">
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn