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

Javascript
JavaScript实现Sleep函数的代码
一个可以显示阴历的JS代码
从csdn弄下来的页面预先载入效果
键盘事件中keyCode、which和charCode 的兼容性测试
一个支持ff的modaldialog的js代码
[js+css]点击隐藏层,点击另外层不能隐藏原层
用javascript实现页面打印的三种方法
HTML-CSS群中单选引发的“事件”
一款不错的键盘密码输入js程序
限制文本字节数js代码
静态图片的十一种滤镜效果--不支持Ie7及非IE浏览器。
用javascript动态调整iframe高度的方法
用一段js程序来实现动画功能
javascript实现划词标记+划词搜索功能
javascript 简单高效判断数据类型 系列函数 By shawl.qiu
服务端 VBScript 与 JScript 几个相同特性的写法 By shawl.qiu
禁止F5等快捷键的JS代码
在textarea文本域中显示HTML代码的方法
Javascript之文件操作
修改发贴的编辑功能

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


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