烦请懂JS的帮我解释一下这段代码
没有学过js,但是在写程序的时候又要用到其中的一段,烦请哪位热心朋友帮我解释一下这段代码干嘛用的,越详细越好,感谢了!代码如下:window.dcHelper=newfu...
没有学过js,但是在写程序的时候又要用到其中的一段,烦请哪位热心朋友帮我解释一下这段代码干嘛用的,越详细越好,感谢了!
代码如下:
window.dcHelper = new function () {
this.setData = function (c) {
var b;
a : {
b = document.getElementById(c);
if ("undefined" === typeof b || null === b) {
var a = document.getElementsByName(c);
"undefined" !== typeof a && (null !== a && 0 < a.length) && (b = a[0])
}
if ("undefined" === typeof b || null === b)
for (var a = 0, e = document.forms.length; a < e; a++)
for (var d = 0, f = document.forms[a], h = f.elements.length; d < h; d++) {
var g = f[d];
if (g.name === c) {
b = g;
break a
}
}
}
"undefined" !== typeof b && null !== b && (a = null, "undefined" !== typeof appidmsparm && null !== appidmsparm &&
(appidmsparm.appidmsform(c), null !== b.value && (a = b.value)), b.value = this.getData(a))
};
this.getData = function (c) {
var b = {};
b.U = navigator.userAgent;
b.L = window.navigator.language ? window.navigator.language : navigator.browserLanguage ? navigator.browserLanguage : "";
var a;
a = (new Date).getTimezoneOffset();
if ("number" !== typeof a || null === a)
a = "";
else {
var e = Math.abs(parseInt(a / 60, 10)),
d = Math.abs(a % 60);
a = "GMT" + (0 < a ? "-" : "+") + (10 > e ? "0" + e : e) + ":" + (10 > d ? "0" + d : d)
}
b.Z = a;
b.V = "1.1";
"undefined" !== typeof c && null !== c && (b.F = c);
return JSON.stringify(b)
}
}; 展开
代码如下:
window.dcHelper = new function () {
this.setData = function (c) {
var b;
a : {
b = document.getElementById(c);
if ("undefined" === typeof b || null === b) {
var a = document.getElementsByName(c);
"undefined" !== typeof a && (null !== a && 0 < a.length) && (b = a[0])
}
if ("undefined" === typeof b || null === b)
for (var a = 0, e = document.forms.length; a < e; a++)
for (var d = 0, f = document.forms[a], h = f.elements.length; d < h; d++) {
var g = f[d];
if (g.name === c) {
b = g;
break a
}
}
}
"undefined" !== typeof b && null !== b && (a = null, "undefined" !== typeof appidmsparm && null !== appidmsparm &&
(appidmsparm.appidmsform(c), null !== b.value && (a = b.value)), b.value = this.getData(a))
};
this.getData = function (c) {
var b = {};
b.U = navigator.userAgent;
b.L = window.navigator.language ? window.navigator.language : navigator.browserLanguage ? navigator.browserLanguage : "";
var a;
a = (new Date).getTimezoneOffset();
if ("number" !== typeof a || null === a)
a = "";
else {
var e = Math.abs(parseInt(a / 60, 10)),
d = Math.abs(a % 60);
a = "GMT" + (0 < a ? "-" : "+") + (10 > e ? "0" + e : e) + ":" + (10 > d ? "0" + d : d)
}
b.Z = a;
b.V = "1.1";
"undefined" !== typeof c && null !== c && (b.F = c);
return JSON.stringify(b)
}
}; 展开
2个回答
2015-01-13
展开全部
你的代码拷贝串了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询