Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to know wich event called the function?

Status
Not open for further replies.

Excko

Programmer
Nov 10, 2003
7
CA
Hi everyone. I have a function that is called by both the onClick event and the onMouseOut event. I would like to know if it's possible to know from inside the function wich event called it. Thanks in advance.
 
An easy way would be to pass an argument to the function:

<script>
function myFunc(onWhat){
alert(&quot;This function was called using the &quot;+onWhat&quot; event.&quot;);
}
</script>
<input type=&quot;text&quot; onclick=&quot;myFunc('onclick')&quot; onmouseout=&quot;myFunc('onmouseout')&quot;>

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
Allright thanks. I should've thought of that ...
*goes crawl in a dark hole to never come out*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top