Cross Browser Event Handler Must Capture [enter]
Inside a function I have an event handler. So far so good. But in that event handler I want to capture Enter pressed and replace that for a HTML. I've done it like this: CrossB
Solution 1:
Shouldn't you be capturing key-code 10 instead of 13? 10 stands for newline character while 13 stands for carriage return.
EDIT: You may be getting the event twice either a) you might have registered it twice or b) event might be bubbling up. For b, I will suggest that you cancel bubbling such as
...
if (keyCode == 13) {
Event.target.ownerDocument.execCommand("inserthtml",false,'<br />');
Event.returnValue = false;
Event.cancelBubble = false;
}
...
Yet, another suggestion is to return false from the event handler function. For example,
...
Event.returnValue = false;
Event.cancelBubble = false;
returnfalse;
}
...
And
CrossBrowserEventHandler(Editor, 'keyup', function(Event) { returnmyFunctionRef(idname, Event) });
Post a Comment for "Cross Browser Event Handler Must Capture [enter]"