Home >Web Front-end >HTML Tutorial >When the mouse is focused on the Text input box, press the Enter key to refresh the page. Reasons and solutions_html/css_WEB-ITnose
Premise: There is only one input box in a form. When the input box gets focus, click Enter, causing the entire page to refresh. Solution to the problem.
1. Process the form
Add events to the form
2. Add a hidden input box, think of changing a single input box
3. Block the Enter key
1> Global method to remove carriage return events
function document.onkeydown() {
var e = event.srcElement ;
if (event.keyCode == 13) {
return false;
} }
}
2> Method to remove the enter event of the input box
onkeydown="return ClearSubmit(event)"
function ClearSubmit(e) {
>