日期:2014-05-17 浏览次数:20504 次
(function(){ var week = '日一二三四五六'; var innerHtml = '{0}:{1}:{2}'; var dateHtml = "{0}月{1}日 周{2}"; var timer = 0; var beijingTimeZone = 8; function format(str, json){ return str.replace(/{(\d)}/g, function(a, key) { return json[key]; }); } function p(s) { return s < 10 ? '0' + s : s; } window.baidu_time = function(time){ initTime = time; show(time); timer = setInterval(function(){ time += 1000; show(time); }, 1000); } function show(time){ var timeOffset = ((-1 * (new Date()).getTimezoneOffset()) - (beijingTimeZone * 60)) * 60000; var now = new Date(time - timeOffset); document.getElementById('time').innerHTML = format(innerHtml, [p(now.getHours()), p(now.getMinutes()), p(now.getSeconds())]); setClockTime(time); document.getElementById('date').innerHTML = format(dateHtml, [ p((now.getMonth()+1)), p(now.getDate()), week.charAt(now.getDay())]); } function init(){ var elm = document.createElement('SCRIPT'); elm.src = 'http://open.baidu.com/app?module=beijingtime&t=' + new Date().getTime(); document.getElementsByTagName('HEAD')[0].appendChild(elm); setTimeout(function(){init()}, 60000); } window.baidu_time(bjtime); })();
------解决方案--------------------
Http Status Code是304 Not Modified,不知道是什么意思