作家
登录

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

作者: 来源:www.28hudong.com 2013-03-30 03:50:38 阅读 我要评论

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>

  推荐阅读

  使用button标签,实现三态图片按钮

三态图片按钮对于好的用户体验来说必不可少。我对dom事件进行一些处理,在不改变html的情况下,实现了三态按钮。下面的解决方法的关键,主要是去掉虚线选框和对背景进行定位,没有使用循环处理,任何一个按钮,只要>>>详细阅读


本文标题:In Javascript Class, how to call the prototype method.(three method)

地址:http://www.17bianji.com/kaifa2/JS/31147.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)