请教网页整点语音报时
下面这段代码当满足了条件他也自动报时了,但网页也同时转到了一个空白页面。不要setInterval的话,网页刷新后才能报时。
请教怎样让网页在不刷新的条件下并且一满足条件就让他自动报时,而且不让网页转到空白页面去?
function bgsound()
{
var time=new Date();
var hours=time.getHours();
var minutes=time.getMinutes();
var seconds=time.getSeconds();
var arr=new Array();
arr[0]="<bgsound src='sound/0.mp3' loop=1>";
arr[1]="<bgsound src='sound/1.mp3' loop=1>";
arr[2]="<bgsound src='sound/2.mp3' loop=1>";
arr[3]="<bgsound src='sound/3.mp3' loop=1>";
arr[4]="<bgsound src='sound/4.mp3' loop=1>";
arr[5]="<bgsound src='sound/5.mp3' loop=1>";
arr[6]="<bgsound src='sound/6.mp3' loop=1>";
arr[7]="<bgsound src='sound/7.mp3' loop=1>";
arr[8]="<bgsound src='sound/8.mp3' loop=1>";
arr[9]="<bgsound src='sound/9.mp3' loop=1>";
arr[10]="<bgsound src='sound/10.mp3' loop=1>";
arr[11]="<bgsound src='sound/11.mp3' loop=1>";
arr[12]="<bgsound src='sound/12.mp3' loop=1>";
arr[13]="<bgsound src='sound/13.mp3' loop=1>";
arr[14]="<bgsound src='sound/14.mp3' loop=1>";
arr[15]="<bgsound src='sound/15.mp3' loop=1>";
arr[16]="<bgsound src='sound/16.mp3' loop=1>";
arr[17]="<bgsound src='sound/17.mp3' loop=1>";
arr[18]="<bgsound src='sound/18.mp3' loop=1>";
arr[19]="<bgsound src='sound/19.mp3' loop=1>";
arr[20]="<bgsound src='sound/20.mp3' loop=1>";
arr[21]="<bgsound src='sound/21.mp3' loop=1>";
arr[22]="<bgsound src='sound/22.mp3' loop=1>";
arr[23]="<bgsound src='sound/23.mp3' loop=1>";
for(var j=0;j<arr.length;j++)
{
if(hours==j && minutes==0 && seconds==0)
{
alert(document.write(arr[j]));
}
}
}
setInterval("bgsound()",1000);