window["这支js的名称"] = window["这支js的名称"] || (function () { try { var ns = function (info) { var ff = this; for (var key in info) { this[key] = info[key]; } if (ff.mainObj == null) { throw "must be have mainObj."; } ff.mainObj.data(ns.moduleName, ff); }; ns.moduleName = "这支js的名称"; ns.prototype.getModuleName = function () { return ns.moduleName; } ns.jQueryPluginName = "这支js的名称"; ns.windowPluginName = "这支js的名称"; //Method这里是一些变数的宣告区域 有点像是全域变数 以下变数皆为举例使用 ns.prototype.getModuleName = function () { return ns.moduleName; } ns.alert = function (msg, func) { if (func == null) { alert("Error(" + ns.moduleName + "): " + msg); } else { alert("Error(" + ns.moduleName + "." + func + "): " + msg); } }; ns.prototype.PreFormCategory = ""; ns.prototype.FlowTestUnitLst = []; ns.prototype.disableValArr = ["依实际数量", "依剩余数量"]; ns.prototype.Asy_DRAM_Last_Step = "LS_MARK0"; ns.prototype.AllowedOwnerCode = ["C", "X", "T"]; ns.prototype.AllowShift = "Y"; ns.prototype.is_DE_User = false; /*---End Template - Basic Code------------------------*/ //EX Function //ns.开头方法 ns.testFunction_01 = function (e) { //do something }; //window[""]开头方法 window["testFunction_02"] = function (e) { //do something }; return ns; } catch (ex) { WbVir.WvErrorHandler.showAlert("Initial 这支js的名称 fail: " + ex); }})();
在Html的tag 写onclick事件写法 EX:
<input type="button" id="btn_test_01" onclick="这支js的名称.testFunction_01()">
//重点
ns.testFunction_01 用法 = window["testFunction_02"]用法
更新 于其他js使用
$(document).ready(function () { $("#btn_click").click(function () { alert(这支js的名称.testFunction_01()); });});
如有谬误请各路大神指导
纯属笔记系列