<SCRIPT LANGUAGE="JavaScript">
<!--
function test()
{
var x = 10;
var y = 20;
this.write = function()
{
var a = function()
{
alert(x);
alert(y);
}
return a;
}
}var t = new test();
var a = t.write();
a();
//-->
</SCRIPT>

解决方案 »

  1.   

    用 var x = 10; 
    不用this.x = 10;see:
    http://dev.csdn.net/article/14/14082.shtm
      

  2.   

    谢谢,但是我的x和y是作为属性要在实例化时自由指定的,必需有this.x和this.y,请问有没有方法获取
      

  3.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function test()
    {
    this.x = 10;
    this.y = 20;
    this.write = function()
    {
        function abc(e)
        {
          return e.x + e.y;
        }
    var a = abc(this)
    return a;
    }
    }var t = new test();
    alert(t.write());
    //-->
    </SCRIPT>