还要能够支持这种
function abc()
{
this.name;
this.gender;
this.open=function()
{
alert(...));
}
}

解决方案 »

  1.   

    <script type="text/javascript">
    function abc(NAME){
    this.name=NAME;
    this.tellMe=function(){
        alert(this.name);
      }
    }
    var o=new abc("abc");
    o.tellMe();
    </script>
      

  2.   

    <script type="text/javascript">
    <!-- function abc()
    {
    this.name;
    this.gender;
    this.open=function()
        {
            alert(this.constructor.toString().replace(/^function\s(\w*)[\s\S]*$/,"$1"));
        }
    }
    var n = new abc();
    n.open();//-->
    </script>你说的两种情况都可以这样来解决,但并不是完善的,因为只有此函数被实例化的时候,this关键字才指向本身,否则指向window/其它.对于直接函数调用,没想到好的办法,可以作为函数参数传进去.
      

  3.   

    梅花雪同志:
    这个不行,因为有时候我的函数是这么定义的
    <script type="text/javascript">
    <!-- abc=function()
    {
    this.name;
    this.gender;
    this.open=function()
        {
            alert(this.constructor.toString().replace(/^function\s(\w*)[\s\S]*$/,"$1"));
        }
    }
    var n = new abc();
    n.open();//-->
    </script>
      

  4.   

    <!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>
    <title>环球旅业</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="../css/global.css">
    <script language="javascript" src="/js0.11/$.js"></script>
    </head>
    <body>
    <script>
    function f1()
    {
    this.ff = function ff() //变通一下
    {
    var v = arguments.callee.toString();
    alert(v.replace(/({(.|[^.])+})|(function)+|(\(\))|\s+/ig,""));
    }
    }
    var f1 = new f1();
    f1.ff();
    </script>
    </body>
    </html>
      

  5.   

    那你还可以遍历自window以下的所有命名空间,看能不能找到当前函数的引用(还有可能有多个哦)
    函数里的私有属性是遍历不到的.