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

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

WBOY
WBOYOriginal
2016-06-24 11:54:501279browse

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

                                                                                                    ​>

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