源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2021-11-01 19:48 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:In Javascript Class, how to call the prototype method.(three method)
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>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部