//从response header中获取服务器当前时间,不存在有缓存时的问题
function getServerTime(){
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != ‘undefined‘) {
xmlHttp = new XMLHttpRequest();
}
xmlHttp.open("GET", window.location.href.toString(), false);
xmlHttp.setRequestHeader("Range", "bytes=-1");
xmlHttp.send(null);
var severtime=new Date(xmlHttp.getResponseHeader("Date"));
return severtime
}原文:http://blog.csdn.net/jyy_12/article/details/13290229