网页现实全球时间表的问题
我根据网上一个全球时间表的例子(在http://www.sucai86.com/texiaofile/1109.htm),做我的网站的全球时间表,但我的网页要求直接在网页上显示各国即时时间,所以我改了一下,但为什么不显示?请高手指点?
[解决办法]
<body>
<input type=text name=zonetime size=28>
<br>
<br>
<b> 当前的地区 </b> <br>
<input type=text name=zonename size=21>
<br>
<br>
<input type=button value= "太平洋 " onClick= "timeCheck(this.value, -480) " name= "button ">
<input type=button value= "北京 " onClick= "timeCheck(this.value, 480) " name= "button ">
<input type=button value= "东京 " onClick= "timeCheck(this.value, 540) " name= "button ">
<input type=button value= "伦敦 " onClick= "timeCheck(this.value, +0) " name= "button ">
</body>
<script language= "JavaScript ">
<!-- Begin
var timerRunning = false;
var timezone = "格林尼治标准时间 ";
var timearea = document.getElementById( "zonetime ");
var zonenamearea = document.getElementById( "zonename ");
zonenamearea.value = timezone;
var timediff = 0;
function window.onload(){drawTime();}
function timeCheck(aa,bb)
{
zonenamearea.value = aa;
timediff = bb;
}
function drawTime()
{
var now = new Date();
now.addMinute(timediff);
timearea.value = now.Format( "MM/dd/yyyy hh:mm:ss ")
setTimeout( "drawTime() ",300);
}
Date.prototype.addMinute = function(num){this.setMinutes(this.getMinutes() + num);return this;}
Date.prototype.Format = function()
{
year = this.getUTCFullYear();
month = this.getUTCMonth()+1;
day = this.getUTCDate();
hour = this.getUTCHours();
minute = this.getUTCMinutes();
second = this.getUTCSeconds();
month = (month <10? "0 ": " ") + month;
day = (day <10? "0 ": " ") + day;
minute = (minute <10? "0 ": " ") + minute;
second = (second <10? "0 ": " ") + second;
str = month + "/ " + day + "/ " + year + " " + hour + ": " + minute + ": " + second;
return str;
}
// End -->
</script>
[解决办法]
2楼的,你这个代码,我用记事本记下来,然后转换为html。网页提示有脚本呢,要按一下才能运行,那么放在网页里,用户也有这个脚本提示??
[解决办法]
楼上的没有问题啊,
有什么脚本提示.
[解决办法]
<table width= "300 " border= "1 " cellspacing= "0 " cellpadding= "0 " id= "Clocks ">
<tr>
<td width= "101 " align= "center "> 太平洋 </td>
<td width= "193 " align= "center " timediff= "-480 "> </td>
</tr>
<tr>
<td align= "center "> 北京 </td>
<td align= "center " timediff= "480 "> </td>
</tr>
<tr>
<td align= "center "> 东京 </td>
<td align= "center " timediff= "540 "> </td>
</tr>
<tr>
<td align= "center "> 伦敦 </td>
<td align= "center " timediff= "0 "> </td>
</tr>
</table>
</body>
<script language= "JavaScript ">
<!-- Begin
//只要是带 timediff属性 的表格单元 就会按照里面的时间差(分钟)变化
var timeout = 300;//这个是刷新频率(毫秒)
var clockArr = new Array();
function window.onload()
{
var clocks = document.getElementById( "Clocks ");
if(clocks!=null && clocks.tagName== "TABLE ")
{
for(var i=0;i <clocks.cells.length;i++)
{
var otd = clocks.cells[i];
var tempstr = otd.getAttribute( "timediff ");
if(tempstr!=null && !isNaN(tempstr))
{
clockArr.push(new clock(tempstr,otd));
}
}
}
setTimeout( "drawTime() ",timeout);
}
function drawTime()
{
for(var i=0;i <clockArr.length;i++)
{
clockArr[i].drawTime();
}
setTimeout( "drawTime() ",timeout);
}
function clock(timediff,timearea)
{
this.timeDiff = parseInt(timediff);
this.timeArea = timearea;
this.drawTime = function()
{
if(this.timeArea!=null && this.timeArea.innerText!=null)
{
time = new Date();
time.addMinute(this.timeDiff);
this.timeArea.innerText = time.Format( "MM/dd/yyyy hh:mm:ss ")
}
}
}
Date.prototype.addMinute = function(num){this.setMinutes(this.getMinutes() + num);return this;}
Date.prototype.Format = function()
{
year = this.getUTCFullYear();
month = this.getUTCMonth()+1;
day = this.getUTCDate();
hour = this.getUTCHours();
minute = this.getUTCMinutes();
second = this.getUTCSeconds();
month = (month <10? "0 ": " ") + month;
day = (day <10? "0 ": " ") + day;
minute = (minute <10? "0 ": " ") + minute;
second = (second <10? "0 ": " ") + second;
str = month + "/ " + day + "/ " + year + " " + hour + ": " + minute + ": " + second;
return str;
}
// End -->
</script>
[解决办法]
PS:同时刷新的时间多的话 就延长下时间刷新间隔