http://xiangai.taobao.com
http://shop148612228.taobao.com

JavaScript 中 arguments,callee,caller,arguments[0] 的理解

arguments.callee.caller.arguments[0] 
用于获取事件对象
argument.callee就是函数本身,caller函数的调用函数.
<input type='text' value='click me' onkeydown="doKeyDown('a')"/>
<script type="text/javascript">
function doKeyDown(arg){
var _e = window.event || arguments.callee.caller.arguments[0];
alert(arguments.callee);
//    将显示 doKeyDown 函数的定义
//    function doKeyDown(arg) {
//        var _e = window.event || arguments.callee.caller.arguments[0];
//        alert(_e);
//        alert(arguments.callee);
//    }
alert(arguments.callee.arguments[0]);
//    将显示 a 即 doKeyDown 参数
alert(arguments.callee.caller);
//    将显示 onkeydown 键盘事件函数的定义
//    function onkeydown(event) {
//        doKeyDown("a");
//    }
alert(arguments.callee.caller.arguments[0]);
//    将显示 [object KeyboardEvent] 即 事件对象
}
</script>

posted @ 2013-06-10 16:02  万事俱备就差个程序员  阅读(1077)  评论(0编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏