| 项目搜索 |
| |
|
代码片段库:
查看代码片段
浏览
| 提交新的代码片段
| 创建代码包
点击显示时间
|
类型:
Full Script |
类别:
HTML Manipulation
|
许可证:
GNU General Public License |
语言:
JavaScript
|
描述:
点击文字链接后出现时间显示,而且是走动的时间,用层实现的
|
该代码片段的版本系列:
片段ID |
下载版本 |
提交时间 |
提交人 |
删除 |
4680 | 1.0 | 2003-10-14 14:35 | cbd001 | |
点击"下载版本"来下载该代码片段.
最新版本的代码片段: 1.0
脚本说明:
第一步:把如下代码加入<body>区域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (document.all){
var wait = 4; //how many seconds it shows the clock
var message = "点击显示时间" //the message
var fgcolor = "yellow" //border and text colors
var bgcolor = "#ffa500" //background color
/////////////DO NOT CHANGE PAST HERE////////////////
width = message.length*20;
var timer = null;
function stop(){
i = 0;
clearTimeout(timer)
document.all.display.innerHTML = message.bold();
}
function start(){
i++
var time = new Date()
var hours = time.getHours()
var minutes = time.getMinutes()
var seconds = time.getSeconds()
var clock = hours
clock += ((minutes < 10) ? ":0" : ":") + minutes
clock += ((seconds < 10) ? ":0" : ":") + seconds
document.all.display.innerHTML = clock.bold();
if (i <= wait)
timer = setTimeout("start()",1000);
else
stop();
}
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (document.all){
document.write('<Div style="background-color:'+bgcolor+'; color:'+fgcolor+'; width:'+width+';border:2 double '+fgcolor+';cursor: hand;">');
document.write('<center><Span id="display" onclick="start()"></Span></Center>');
document.write('</Div>');
}
// End -->
</script>
第二步:把<body>中的内容改为:
<body onLoad="stop()">
如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来. |
|