Home >Web Front-end >JS Tutorial >Obtain Event object and keyCode_javascript techniques under Firefox

Obtain Event object and keyCode_javascript techniques under Firefox

WBOY
WBOYOriginal
2016-05-16 18:58:461237browse
Copy code The code is as follows:

var isie = (document.all) ? true:false;
var key;
var ev;
if(isie){
key = window.event.keyCode;
ev = window.event;
}else{
key = e .which;
ev = e;
}

At this time, you can alert(key) to see,
But if you want to use
ev.returnValue = true; // IE
ev.preventDefault(); // Mozilla Firefox
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