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

Javascript
在Z-Blog中运行代码[html][/html](纯JS版)
统一接口:为FireFox添加IE的方法和属性的js代码
网页自动刷新,不产生嗒嗒声的一个解决方法
驱动事件的addEvent.js代码
[原创]提供复制本站内容时出现,该文章转自IT学习网等字样的js代码
CSDN轮换广告图片轮换效果
一段多浏览器的"复制到剪贴板"javascript代码
Javascript中的常见排序算法
JS Common 2 之比较常用到的函数
非正则实现的只能输入汉字的输入框
CSDN上快速结贴的方法,JS实现
js eval木马代码,以后再分析吧
屏蔽鼠标右键、Ctrl+n、shift+F10、F5刷新、退格键 的javascript代码
一个不错的可以检测多中浏览器的函数和其它功能
状态栏显示欢迎信息的脚本特效
关于文本限制字数的js代码
在你的网页中嵌入外部网页的方法
在IE中调用javascript打开Excel的代码(downmoon原作)
javascript实现动态增加删除表格行(兼容IE/FF)
javascript中获取选中对象的类型

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


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