//获取服务器时间 var getServerDate = function () { var xmlHttpRequest = null, serverDate = new Date(); if (window.ActiveXObject) { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) { xmlHttpRequest = new XMLHttpRequest(); } else { xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } //同步请求 HEAD请求仅获取HEAD信息 xmlHttpRequest.open('HEAD', '/', false); xmlHttpRequest.send(null); if (xmlHttpRequest.status === 200) { // 获取请求响应头里的时间戳 serverDate = new Date(xmlHttpRequest.getResponseHeader("Date")); } return serverDate; }