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

Javascript
Prototype使用指南之form.js
Prototype1.5 rc2版指南最后一篇之Position
javascript 对象的定义方法
JS多级连动菜单
javascript编程起步(第一课)
javascript编程起步(第二课)
java script编程起步(第三课)
jquery简单体验
javascript编程起步(第四课)
javascript编程起步(第五课)
javascript编程起步(第六课)
javascript编程起步(第七课)
javascript object oriented 面向对象编程初步
js宝典学习笔记(上)
JS宝典学习笔记(下)
javascript基础的动画教程,直观易懂
javascript 的面向对象特性参考
JScript|Event]面向事件驱动的编程(二)--实例讲解:将span模拟成超连接
JScript面向事件驱动的编程
一份老外写的XMLHttpRequest代码多浏览器支持兼容性

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 94 ::
收藏到网摘: 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>