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

Javascript
Javascript开发包大全整理
获取Javscript执行函数名称的方法
间隔滚动效果-兼容IE和FireFox
使用Modello编写JavaScript类
一个最简单的级联下拉菜单
用Javascript实现UTF8编码转换成gb2312编码
添加到收藏夹的Javascript脚本 for ie,firefox
一些常用的Javascript函数
颜色选择: ColorMatch 5K
Javascript实现的分页函数
在IE下:float属性会影响offsetTop的取值
用javascript获取地址栏参数
人民币数字转换成大写形式
改进:论坛UBB代码自动插入方式
获取table中的rowIndex和cellIndex
JavaScript事件列表解说
取得input元素中部分选中(selected)的值
破解md5加密扫描程序(适合扫描弱密码)[
JavaScript中Array 对象相关的几个方法
Javascript直接定义对象实例[

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


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