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

Javascript
打开windows运行对话框的js
[原创]保存的js无法执行的解决办法
可以关闭计算机的js脚本
JavaScript中void(0)的具体含义解释
javascript编程起步(第三课)
javascript第一课
javascript里的条件判断
setTimeout和setInterval的浏览器兼容性分析
js实现图片等比缩略显示 支持IE/FF
特殊数据的js四舍五入问题
求解开jscript.encode代码的asp函数
用javascript实现“闪动”标题栏
用javascript实现记录来宾姓名的代码
[JS]实现动态增加框架!未完成
用js一招破解所有网页的加密源代码的方法
窗口没有提示自动关闭的js代码
解决远程页面抓取中的乱码问题?
如何实现从照片中裁切自已的肖像呢?
参考:关于Javascript中实现暂停的几篇文章
Javascript中暂停功能的实现代码

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


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