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.