You are here: irt.org | FAQ | JavaScript | Misc | Q536 [ previous next ]
A function can find out which function called it using the caller property:
<script language="JavaScript"><!--
function x() {
alert('function x() was invoked by function ' + x.caller);
}
function y() {
x();
}
y();
//--></SCRIPT>A function can be easily passed the object in question using "this":
<script language="JavaScript"><!--
function test(what) {
alert(what.href);
}
//--></script>