b0 is my binding method which calls the code to run after an enter press. o5 simply gets the elements onkeypress and sets the callback to b0. This does not work. This worked when I had the b0 attached to the onkeypress event wih inline registration. How is b0 suppose to know开发者_JAVA技巧 what 'event' is? With inline registration it "knows", with advanced registration event is just another variable I'm guesssing?
function b0(event)
{if (event.keyCode==13)
{i4();
return false;}}
function o5('f4b_',b0);
o5(a,b){document.getElementById(a).onkeypress=b;}
The problem is that you're passing a string to o5
, and assigning that string to the onkeypress
property of the element, when really you want to be passing a reference to the function:
o5('f4b_', b0); //No quotes!
That should fix it. Also, I'm assuming it's just a typo when writing the question, but you're missing the function
keyword before the definition of o5
.
See it working here.
精彩评论