Home >
Web Front-end >
JS Tutorial >
Browser script compatibility. Compatibility of events triggered by the enter key in the text box_javascript skills
Browser script compatibility. Compatibility of events triggered by the enter key in the text box_javascript skills
WBOY
Release: 2016-05-16 18:24:42
Original
1136 people have browsed it
It is very simple to determine whether the pressed key is Enter:
function EnterPress(){ if(event.keycode == 13){ ... } }
IE6’s onkeypress will accept the "Enter event" , and onkeydown will not accept IE8's onkeypress will not accept "Enter event", but onkeydown will accept ... Don't worry about this, just write both
However, when it comes to FF, there will be contradictions. FF accepts "Enter events" onkeypress and onkeydown. At the same time, in order to be compatible with FF, it can be obtained below event, you need to write it like this:
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