jscript的自定义对象的方法中访问对象本身的方法有几种?
例如:
以下代码定义了一个自定义对象及其属性property1和方法function1:
function MyObject()
{
this.property1="abc";
this.function1=function1;
}
function function1()
{
alert(this.property1)
}
如果这样使用,没有问题,可以得到正确结果(对话框显示"abc")
var oTest=new MyObject();
oTest.function1();
但是如果在事件中使用:
<input id="input1" type="text" onchange="oTest.function1()">
就会出错,因为此时this指针指向该input而不是oTest!!
请问此时function1中有办法访问到对象的属性property1吗?
万分感激!