function callerDemo() {
    if (callerDemo.caller) {
        var a= callerDemo.caller.arguments[0];
        alert(a);
    } else {
        alert("this is a top function");
    }
}
function handleCaller() {
    callerDemo();
}

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head><body>
    <script type="text/javascript">
    function Person() {
    alert(Person.caller);
    }/*function A() {
    new Person();
    }*/
    function A(a) {
    this.a = a;
    }
    A.prototype.sayHi = function() {
    alert(this.a);
    }
    var person = new Person();
    var as = new A(person);
    as.sayHi(); 
    </script>
    </body>
    </html>
      

  2.   

    本来想着用函数创建一Dom元素,然后根据Dom元素找到创建它的函数,想起了用caller,感觉不行
      

  3.   

    caller是函数对象的属性,dom元素不是一个函数对象。