var JSHelper = {};
JSHelper = {
//创建GUID
CreateGUID: function () { var g = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; while (/x/.test(g)) g = g.replace(/x/, "0123456789abcdef".substr(parseInt(Math.random() * 16), 1)); return g; },
//对象复合
//例:var cfg = JSHelper.ObjectExtend(cfg,cfgDefault);
ObjectExtend: function (obj, exts, overwrite) {
exts = (typeof exts != "object") ? {} : exts;
overwrite = (typeof overwrite != "boolean") ? false : overwrite;
for (var n in exts) {
if (!(n in obj) || overwrite) {
try { obj[n] = exts[n]; }
catch (e) { }
}
}
return obj;
},
//取得页面body的信息,如高/宽,卷去上/左.
//例:var pageWidth = JSHelper.GetPageInfo().Width;
GetPageInfo: function () {
var PageInfo = {};
PageInfo.Height = document.body.clientHeight ? document.body.clientHeight : document.documentElement.clientHeight;
PageInfo.Width = document.body.clientWidth ? document.body.clientWidth : document.documentElement.clientWidth;
PageInfo.ScrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
PageInfo.ScrollLeft = document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft;
return PageInfo;
}
};
js工具类
最新推荐文章于 2024-04-08 15:48:59 发布