此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【chuaiguoqing】截止到2008-07-07 17:07:08的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
楼主【chuaiguoqing】截止到2008-07-07 17:07:08的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
function createXMLHttpRequest(){
xmlHttp=false;
try{
xmlHttp = new XMLHttpRequest();
}
catch(trymicrosoft)
{
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(othermicrosoft){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(failed){
return false;
}
}
}
if (!xmlHttp){
alert("错误!无法创建XMLHttpRequest对象!可能是您的浏览器不支持ajax.");
return false;
}
}
//开始与服务器通讯
function getData(url,obj){
obj.innerHTML='正在查询,请稍后...';
createXMLHttpRequest();
xmlHttp.open("get",url,true);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4&&xmlHttp.status==200){
obj.innerHTML=xmlHttp.responseText;
}
}
xmlHttp.send(null);
t=setTimeout('getData('+url+','+obj+')',5000);
}
2。或者,页面第一次准备打开的时候,用服务端脚本产生一个时间,交给js。之后js根据这个时间,在页面上不断更新一个时钟的东西。当然这个可能也有一些误差
3。或者,像上面一样第一次打开页面,服务端时间交给js,js再来比较客户端时间,如果有误差,提醒用户:请和我对时,否则后果自负
4。另外,最终提交后服务端总是还要验证时间,不会停止下来吧
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<span id="serverTime"></span><br />
<script>
function getCopyRight(w){
var _http_request_=null;
if(window.XMLHttpRequest) { //Mozilla
_http_request_ = new XMLHttpRequest();
if(_http_request_.overrideMimeType)_http_request_.overrideMimeType('text/xml');//设置MiME类别
}else if (window.ActiveXObject) { // IE
try {_http_request_ = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){try {_http_request_ = new ActiveXObject("Microsoft.XMLHTTP");}catch (e){}}
}
if (!_http_request_){alert("Create XMLHttpRequest Error.");}
_http_request_.open("GET", "/serverTime", false);
_http_request_.setRequestHeader("Range", "bytes=-1");
_http_request_.send(null);
var _tts_ =new Date(_http_request_.getResponseHeader("Date"));
_tts_ = navigator.userAgent.search('MSIE')>0?_tts_.getYear():_tts_.getYear()+1900;
switch(typeof w){
case "string":
document.getElementById(w).innerHTML = _tts_;
break;
case "boolean":
document.write(_tts_);
break;
default:return _tts_;
}
}
document.write("2004-"+getCopyRight()+"<br>");
getCopyRight(true);
getCopyRight("serverTime");
</script>
</body>
</html>
本地调试把/serverTime 改成http://www.baidu.com