本帖最后由 耗子 于 2012-12-24 10:43 编辑
再刷新就又正常了
var AjaxLite = {
Browser: {
IE: !!(window.attachEvent && !window.opera),
Opera: !!window.opera,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
},
IE: __getIE(),
mode: {
Post: "Post",
Get: "Get"
},
getRequest: function () {
if (window.XMLHttpRequest) {
return new XMLHttpRequest()
} else {
try {
return new ActiveXObject("MSXML2.XMLHTTP")
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
return false
}
}
}
}
};
function __getIE() {
if (window.ActiveXObject) {
var v = navigator.userAgent.match(/MSIE ([^;]+)/)[1];
return parseFloat(v.substring(0, v.indexOf(".")))
}
return false
};
Array.prototype.foreach = function (func) {
if (func && this.length > 0) {
for (var i = 0; i < this.length; i++) {
func(this)
}
}
};
String.format = function () {
if (arguments.length == 0) return null;
var str = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var regExp = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
str = str.replace(regExp, arguments)
}
return str
};
String.prototype.startWith = function (s) {
return this.indexOf(s) == 0
};
String.prototype.endWith = function (s) {
var d = this.length - s.length;
return (d >= 0 && this.lastIndexOf(s) == d)
};
String.prototype.trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, '')
};
function getid(id) {
return (typeof id == 'string') ? document.getElementById(id) : id
};
document.getElementsByClassName = function (name) {
var tags = document.getElementsByTagName('*') || document.all;
var els = [];
for (var i = 0; i < tags.length; i++) {
if (tags.className) {
var cs = tags.className.split(' ');
for (var j = 0; j < cs.length; j++) {
if (name == cs[j]) {
els.push(tags);
break
}
}
}
}
return els
};
var getby = document.getElementsByClassName;
function Cookie() { }
Cookie.Save = function (n, v, mins, dn, path) {
if (n) {
if (!mins) mins = 365 * 24 * 60;
if (!path) path = "/";
var date = new Date();
date.setTime(date.getTime() + (mins * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
if (dn) dn = "domain=" + dn + "; ";
document.cookie = name + "=" + value + expires + "; " + dn + "path=" + path
}
};
Cookie.Del = function (n) {
save(n, '', -1)
};
Cookie.Get = function (n) {
var name = n + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca;
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(name) == 0) return c.substring(name.length, c.length)
}
return ""
};
function getcookie(name) {
var cookie_start = document.cookie.indexOf(name);
var cookie_end = document.cookie.indexOf(";", cookie_start);
return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
function setcookie(cookieName, cookieValue) {
var expires = new Date();
var now = parseInt(expires.getTime());
var et = (86400 - expires.getHours() * 3600 - expires.getMinutes() * 60 - expires.getSeconds());
expires.setTime(now + 1000000 * (et - expires.getTimezoneOffset() * 60));
document.cookie = escape(cookieName) + "=" + escape(cookieValue) + ";expires=" + expires.toGMTString() + "; path=/";
}
function getOffsetTop(el, p) {
var _t = el.offsetTop;
while (el = el.offsetParent) {
if (el == p) break;
_t += el.offsetTop
}
return
太长,以上只是一部分 |