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.