当前位置: 首页 > 图文教程 > 网络编程 > Javascript > In Javascript Class, how to call the prototype method.(three method)

Javascript
JavaScript[对象.属性]集锦之五
JavaScript[对象.属性]集锦之六
JavaScript[对象.属性]集锦之七
JavaScript[对象.属性]集锦之八
JavaScript[对象.属性]集锦之九
JavaScript[对象.属性]集锦之十
javascript进行客户端数据的校验(1)
javascript进行客户端数据的校验(2)
用JavaScript实现变色背景和文字(2)
用JavaScript实现文件夹轻松加密
初学Javascript之cookie篇(1)
初学Javascript之cookie篇(2)
初学Javascript之cookie篇(3)
初学Javascript之cookie篇(4)
JavaScript学习:基础继承机制(1)
JavaScript学习:基础继承机制(2)
JavaScript对象与数组参考大全(1)
JavaScript对象与数组参考大全(2)
JavaScript对象与数组参考大全(3)
JavaScript对象与数组参考大全(4)

In Javascript Class, how to call the prototype method.(three method)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 222 ::
收藏到网摘: n/a

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.
<SCRIPT LANGUAGE="JavaScript">
<!--
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("<a href='javascript:void(0);' onclick='" + this.instanceName + ".callback();'>instance call prototype function.</a>")
};
myClass.prototype.callback=function()
{
alert("blueDestiny, never-online");
};
var a = new myClass("a");
a.toAlert();
//-->
</SCRIPT>