<script type="text/javascript">
function whoCallMe(){
alert("my caller is"+whoCallMe.caller);//输出自己的Caller
}
function callerA(){
whoCallMe();
};
function calllerB(){
whoCallerMe();
};
window.onload=function(){
alert(whoCallMe.caller);
alert(whoCallMe());
callerA();
}
</script>
function whoCallMe(){
alert("my caller is"+whoCallMe.caller);//输出自己的Caller
}
function callerA(){
whoCallMe();
};
function calllerB(){
whoCallerMe();
};
window.onload=function(){
alert(whoCallMe.caller);
alert(whoCallMe());
callerA();
}
</script>
本文通过几个简单的JavaScript函数示例介绍了如何在一个函数内部调用另一个函数,并展示了如何使用caller属性来检查函数调用者。但需要注意的是,在现代JavaScript中caller属性被视为不安全并可能被禁用。

1360

被折叠的 条评论
为什么被折叠?



