<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>
<!--
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>
不用this.x = 10;see:
http://dev.csdn.net/article/14/14082.shtm
<!--
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>