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

Javascript
javascript 汉字与拼音转换
JavaScript使用cookie
大平洋汽车网左侧菜单
使用JS操作页面表格,元素的一些技巧
分享我学习js的过程 作者aircy javascript学习教程
张孝祥JavaScript学习阶段性总结(2)--(X)HTML学习
用js来生成随机彩票号码清单
发一个数据过滤的代码,很简单,有用的着的拿去
如何在标题栏显示框架内页面的标题
js滚动条多种样式,推荐
再次更新!MSClass (Class Of Marquee Scroll通用不间断滚动JS封装类 Ver 1.6)
符合web标准的连续滚动图像的js代码
使用iframe作为日历的载体,不再被select和flash等控件挡住的日期输入框
通过脚本控制指定内容不能被选择
模拟弹出窗口效果,关闭层之前,不能选择后面的页内容
另类弹出窗口,跳过所有拦截工具
使用prototype.js进行异步操作
JS模拟多线程
动态增加/删除文件域
[分享]一个非常漂亮的进度滚动条

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


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