Redirecting to another page after pressing Enter key in jQuery

Posted by SheoNarayan under jQuery category on | Points: 40 | Views : 11347
This code snippet shows how to redirect user to another page when user enters some keyword and press Enter key. This is particularly useful in Quick search box scenario.

 $("#txtSearchBox").keypress(function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code.toString() == 13) {
QLSearch(); // call the function to redirect to another page
return false;

// Function that redirect the user to another page
function QLSearch() {
window.location = "/Search.aspx";

Hope this will be useful for someone looking for it.

Comments or Responses

Posted by: Bugwee on: 4/17/2011 Level:Starter | Status: [Member] | Points: 10
thanks Sheo,

i'm going to implement this one on my page... useful...
Posted by: Akiii on: 4/19/2011 Level:Bronze | Status: [Member] | Points: 10
Sir, i have a button. When i press this it must redirect to another page. I am doing this using jquery but cannot successfully do it.....

Can you please help....?

Thanks and Regards
Posted by: Bugwee on: 4/19/2011 Level:Starter | Status: [Member] | Points: 10
Posted by: Akiii on: 4/19/2011 Level:Bronze | Status: [Member] | Points: 10
I have got the answer.......bugwee helped me in achieving it......thanks to him....


Login to post response