I am trying to code something that allow user pressing enter and get the result of the request following the text inputted. The following code work fine with Chrome but not with IE 8 and 7 (I haven't trying the other version of IE) I used Jquery for the first time:
function ifEnterClick(event) {
if (event.keyCode == 13) {
var elm = '#findButton';
$(elm).click();
}
}
and I tried javaScript too:
function ifEnterClick(event) {
if (event.keyCode == 13) {
var obj = document
.getElementById("findButton");
fireEvent(obj, 'click');
}
}
function fireEvent(obj, evt) {
var fireOnThis = obj;
if (document.createEvent) {
var evObj = document.createEvent('MouseEvents');
evObj.initEvent(evt, true, false);
fireOnThis.dispatchEvent(evObj);
} else if (document.createEventObject) {
var evObj = document.createEventObject();
fireOnThis.fireEvent('on' + evt, evObj);
}
}
In both case it work with Chrome but not IE.