4

If enter key is pressed and then search button clicked event is called. My chrome doesn't work . IE is OK . How do I fix ? Thanks in advance

$('#txtSearch').keypress(function(e){
  if(e.keyCode==13)
  $('#btnSearch').click();
});

});

  • Check the Program Console for any javascript errors – TARUN Apr 13 '17 at 13:54
  • It shows me "search is not defined" JS is Ok to work IE not chrome. – Mathew Apr 13 '17 at 15:07
  • And also I found this error in chrome: This page isn’t working Chrome detected unusual code on this page and blocked it to protect your personal information (for example, passwords, phone numbers, and credit cards). Try visiting the site's homepage. ERR_BLOCKED_BY_XSS_AUDITOR – Mathew Apr 13 '17 at 15:40
2

For chrome the variable name is different, so following should help:

$('#txtSearch').keypress(function(e){
  var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
  if(key == 13)
     $('#btnSearch').click();
  });
});

e.charCode is used in Chrome

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.