Quote:
|
so rather than going to a url i need it to run a javascript function
|
You didn't specify what javascript function you wanted to run or what the function is supposed to do.
Getting your script to run a function instead of the command location.href='url' is rather easy.
But I see that you are originally loading the location.href from a PHP function.
So I am a little confused as to what it is you are trying to accomplish.
But no matter, here is how you run a javascript function instead of a command.
Example:
HTML Code:
<html>
<head>
<script language="javascript">
function init_keyboard_events()
{
if(document.all){document.onkeypress = handler;}
else{window.onkeypress = handler;}
}
function handler(e)
{
var x = document.all ? window.event.keyCode : e.charCode;
if(x == 119){do_something();}
}
function do_something()
{
alert("Doing something.");
}
</script>
</head>
<body onload="init_keyboard_events();">
</body>
</html>