化拓教育网
您的当前位置:首页InJavascriptClass,howtocalltheprototypemethod.(threemethod)_javascript技巧

InJavascriptClass,howtocalltheprototypemethod.(threemethod)_javascript技巧

来源:化拓教育网


1、Using Javascript eval Method。
2、using a veriables save object "this" reference.
3、in innerHTML, we can using String to pass the prototype Method。

e.g.


function myClass(instanceName)
{
this.instanceName = instanceName;
this.instance = this;
return this;
};
myClass.prototype.toAlert=function()
{
eval(this.instanceName).callback(); // the first method to call prototype function.
this.instance.callback(); // the second method to call prototype function.

// the third method to call prototype function.
document.write("instance call prototype function.")
};
myClass.prototype.callback=function()
{
alert("blueDestiny, never-online");
};
var a = new myClass("a");
a.toAlert();
//-->

显示全文