始终在页面右下脚的浮动的时钟

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

<!--要完成此效果把如下代码加入到<body>区域中-->

<script>

function syeClock() {

if (!document.layers && !document.all)

return;

timePortion = new Array;

maxLength = new Array;

var runTime = new Date();

timePortion[0] = runTime.getHours();

timePortion[1] = runTime.getMinutes();

timePortion[2] = runTime.getSeconds();

maxLength[0] = 5;

maxLength[1] = 6;

maxLength[2] = 6;

var decValue = 0;

var decMod = 0;

var temp = "";

var hoursBackground = "#7B7BB5";

var minutesBackground = "#4D5487";

var secondsBackground = "#424A63";

var colonBackground = "#000000";

var textColor = "#FFFFFF";

for (var curPor = 0; curPor <= 2; curPor++) {

decValue = timePortion[curPor];

timePortion[curPor] = "";

while (decValue != 0) {

decMod = decValue % 2;

decValue = Math.floor(decValue / 2);

timePortion[curPor] = decMod + timePortion[curPor];

}

if (timePortion[curPor].length < maxLength[curPor]) {

for (var i = 1; i <= maxLength[curPor] - timePortion[curPor].length; i++) {

temp += "0";

}

}

timePortion[curPor] = temp + timePortion[curPor];

temp = "";

}

movingtime = '<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor='+ hoursBackground +'><font color='+ textColor +'>' + timePortion[0] + '</font></td><td bgcolor='+ colonBackground +'>:</td><td bgcolor='+ minutesBackground +'><font color='+ textColor +'>' + timePortion[1] + '</font></td><td bgcolor='+ colonBackground +'>:</td><td bgcolor='+ secondsBackground +'><font color='+ textColor +'>' + timePortion[2] + '</font></td></tr></table>';

if (document.layers) {

document.layers.clock.document.write(movingtime);

document.layers.clock.document.close();

}

else if (document.all) {

clock.innerHTML = movingtime;

}

setTimeout("syeClock()", 1000)

}

window.onload = syeClock;

</script>

<p align="center">

二进制时钟<br>

<span id="clock" style="position:relative;"></span>

</p>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航