Forum Moderators: open

Message Too Old, No Replies

How to get the function responding to a specific event?

         

ericazhj

8:13 am on Mar 9, 2007 (gmt 0)

10+ Year Member



Hi,

I want to know how to get the specific event handler responding o a specific event. I want to get this by use of Javascript.

For example,

<form> First Name:
<input type="text" id="txt1"
onkeyup="showHint(this.value)">
</form>

Here, if I know onkeyup event, I want to know the function responding to this event (Here it is showHint). I do not know how to get this kind of information, because there is no such property or method to help me do this kind of things.

Could you give me some idea?

daveVk

10:46 am on Mar 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In this example the function is actually an unnamed function that calls the function showHint. The equiv javascript assignment is something.onkeyup=function(){showHint(this.value)} You would need to search within a text representation of the function, I do not know how to get that.

Tom_Ruskin

4:04 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



I'm sorry but I couldn't understand the thing clearly. Anyways as much as I grabbed, one solution goes like this:
function whichevent(e){
var val=e.srcElement;
showHint(val.value);
}
call this function in the body tag.
<body onkeyup="whichevent(event)">

Please reply with the outcome.