主文件:webapplication.js
window.usingNamespace = function (a) {
var ro = window;if (!(typeof (a) === "string" && a.length != 0)) {
return ro
};
var co = ro;
var nsp = a.split(".");
for (var i = 0; i < nsp.length; i++) {
var cp = nsp[i];
if (!ro[cp]) {
ro[cp] = {}
};
co = ro = ro[cp]
};
return co
};
页面js
usingNamespace("mytest.testhtml")["selectarea"] = {
getarea : function () {
var p = $("[name='p1']").val();
$("#result").text(p);
},
setarea: function () {
//alert(mypcas);
mypcas = new PCAS("p1", "c1", "a1", "江苏省", "徐州市", "沛县");
}
}
前台调用:
<input type="button" οnclick="mytest.testhtml.selectarea.getarea();" value="getarea" />