In Javascript Class, how to call the prototype method.(three method)
时间:2007-01-09 点击:173
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>
Prototype使用指南之string.js
Prototype最新版(1.5 rc2)使用指南(1)
个人总结的一些关于String、Function、Array的属性和用法
[JS源码]超长文章自动分页(客户端版)
Javascript与vbscript数据共享