Without further ado, here’s the code:
document. onkeydown=function()
{
var EventUtil = {};
EventUtil.getEvent = function(){
if(window.event){return window.event;}
else{ return EventUtil.getEvent.caller.arguments[0];}
}
var button = document.getElementById("qw");
if(EventUtil.getEvent().keyCode==13)
{
button.click();
event.returnValue = false;
}
}
For comparison: uploading one does not support IE, but Support FireFox:
window.onkeydown=function()
{
var EventUtil = {};
EventUtil.getEvent = function(){
if(window.event){return window.event;}
else{return EventUtil.getEvent.caller .arguments[0];}
}
//Bind your button event with id qw
var button = document.getElementById("qw");
if(EventUtil.getEvent().keyCode==13 )
{
button.click();
event.returnValue = false;
}
}
Do you see any difference?
The above is for reference only.
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