某个著名博客上面的一段孤立的代码,大体结构为
(function() {这儿为具体代码})();
这样的函数,自己不运行,也无名称,其他人怎么调用阿;
具体如下:
(function() {
var p = P(N.ui),
um;
p.agC = C();
um = p.agC.ae(p.eJ, true);
um.av = function(az, A) {
this.acf = 'key-' + U.bF(5);
this.aw(az, A);
};
um.ax = function(A) {
p.agC.ar.ax.call(this, A);
A = A || O;
this.gH = A.tag || '';
this.ve = E.aM(A.sbody);
this.Hw = A.handler || '';
this.bxE = !!A.useclass;
this.Uw = A.noselect || 'noselect';
this.I('onchange', A.onchange || F);
};
um.hZ = function(az) {
this.dK = E.aM(az);
if (!!this.dK) this.aS();
};
um.aS = function() {
this.Lc();
for (var i = this.dH.length - 1; i >= 0; this.aGg(this.dH[i]), i--);
};
um.hA = function(bD, auu) {
bD = bD || 'id';
var aP = [];
for (var i = 0,
l = this.dH.length; i < l; aP.push(this.dH[i][bD]), i++);
return aP.join(auu || ',');
};
um.aX = function() {
V.I(document, 'mouseup', this.Gb.D(this));
V.I(document, 'mousemove', this.tf.D(this));
};
um.aGg = function(as) {
if (!!as[this.acf]) return;
as[this.acf] = true;
as = this.aZd(as);
V.I(as, 'dragstart', V.aN);
V.I(as, 'mousedown', this.rW.D(this));
};
um.Yd = function(as) {
return ! !as[this.acf];
};
um.aZd = function(as) {
var G = !!this.Hw && E.bc(as, this.Hw) || null;
return G && G[0] || as;
};
um.FK = function(aec, aeK) {
if (!!aeK) B.eq ? document.body.onselectstart = F: E.ad(document.body, this.Uw);
else B.eq ? document.body.onselectstart = null: E.ag(document.body, this.Uw);
};
um.Lc = function() {
this.dH = (!this.bxE ? E.bc(this.dK, this.gH) : E.ah(this.dK, this.gH)) || [];
};
um.rW = F;
um.tf = F;
um.Gb = F;
})();
(function() {这儿为具体代码})();
这样的函数,自己不运行,也无名称,其他人怎么调用阿;
具体如下:
(function() {
var p = P(N.ui),
um;
p.agC = C();
um = p.agC.ae(p.eJ, true);
um.av = function(az, A) {
this.acf = 'key-' + U.bF(5);
this.aw(az, A);
};
um.ax = function(A) {
p.agC.ar.ax.call(this, A);
A = A || O;
this.gH = A.tag || '';
this.ve = E.aM(A.sbody);
this.Hw = A.handler || '';
this.bxE = !!A.useclass;
this.Uw = A.noselect || 'noselect';
this.I('onchange', A.onchange || F);
};
um.hZ = function(az) {
this.dK = E.aM(az);
if (!!this.dK) this.aS();
};
um.aS = function() {
this.Lc();
for (var i = this.dH.length - 1; i >= 0; this.aGg(this.dH[i]), i--);
};
um.hA = function(bD, auu) {
bD = bD || 'id';
var aP = [];
for (var i = 0,
l = this.dH.length; i < l; aP.push(this.dH[i][bD]), i++);
return aP.join(auu || ',');
};
um.aX = function() {
V.I(document, 'mouseup', this.Gb.D(this));
V.I(document, 'mousemove', this.tf.D(this));
};
um.aGg = function(as) {
if (!!as[this.acf]) return;
as[this.acf] = true;
as = this.aZd(as);
V.I(as, 'dragstart', V.aN);
V.I(as, 'mousedown', this.rW.D(this));
};
um.Yd = function(as) {
return ! !as[this.acf];
};
um.aZd = function(as) {
var G = !!this.Hw && E.bc(as, this.Hw) || null;
return G && G[0] || as;
};
um.FK = function(aec, aeK) {
if (!!aeK) B.eq ? document.body.onselectstart = F: E.ad(document.body, this.Uw);
else B.eq ? document.body.onselectstart = null: E.ag(document.body, this.Uw);
};
um.Lc = function() {
this.dH = (!this.bxE ? E.bc(this.dK, this.gH) : E.ah(this.dK, this.gH)) || [];
};
um.rW = F;
um.tf = F;
um.Gb = F;
})();
解决方案 »
- 动态导航栏
- parseFloat计算有问题?在线等待!1.66+1.77=3.4299999999999997
- 谁有关于cookie的源码:cookie.js。发我一下。谢谢!
- 请问 大家有没有用ARCIMS的JAVAVIEWER例子进行开发的?
- 求助 关于onclick的问题
- [求救醒目]如何用javascript实现跨页面存储?[求救醒目]
- 高分看看这段代码:<input type='hidden' name=abc value='a'><input type='hidden' name=abc value='b'>为什么提交后只有一个参数能传上
- document.write("<%=server.htmlencode(HTMLstr)%>");
- 求,showModalDialog,dialogArguments.bodytext的意义和参数??急!
- 关于jquery元素获取
- 求:baidu,google,sogou地图使用分析
- json数据
(function(){test=123}());
alert(test);//弹出123var tmp=function(){var test='abc'; return test;}();
alert(tmp);//弹出abc这种函数最多的用处就是闭包。
()运算符计算并且返回表达式的值(注意不要和方法调用后面的‘()’混淆)
则 (function(){})返回这个function
(function())()返回这个function并且用'()'调用执行这个function
um;
p.agC = C();um 是全局变量。外面可以访问
最后一个括号意味着调用。这样做好处:
函数体内定义的var和function,只在函数体内有效,不会造成不同文件之间的变量冲突