I'm trying get my <a>
tag triggered when the user press on the "enter" key. (onkeypress)
.
my <a>
tag:
<a href="javascript:search()" onkeypress="return runScript(event)">
this is my javascript :
function runScript(e)
{
if (e.keyCode == 13) {
alert("dssd");
return false;
}
}
I dont know whats messed up ?
its work for me
<a href="javascript:search();" onkeypress="return runScript(event);">Open in new window using javascript</a>
javaScript
window.runScript = function (e) {
if (e.keyCode == 13) {
alert('ss');
return false;
}
else {
return true;
}
}
window.search = function () {
alert('s');
}
live demo : fiddle