| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1322 人关注过本帖
标题:求助((第一回发帖)
只看楼主 加入收藏
小心小七
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-3
收藏
 问题点数:0 回复次数:6 
求助((第一回发帖)
我想把一个时钟代码
<body bgcolor="#fef4d9" ONLOAD=show5()>
......
和一个倒计时代码
<BODY Onload="startclock()">
......
同时写进一个网页里,可不管怎么弄,倒计时就是不会运行,而且一预览两个的话,就会自动改成ONLOAD=show5()...

问题很弱,希望大家别见笑...
搜索更多相关主题的帖子: 发帖 时钟 网页 倒计时 
2008-04-03 21:04
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
收藏
得分:0 
帖你完整代码来看看.......
2008-04-04 01:05
小心小七
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-3
收藏
得分:0 
回复 2# 的帖子
这是倒计时的.
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var Temp2;
var timerID = null;
var timerRunning = false;
function arry() {
this.length = 12;
this[0] = 31;
this[1] = 28;
this[2] = 31;
this[3] = 30;
this[4] = 31;
this[5] = 30;
this[6] = 31;
this[7] = 31;
this[8] = 30;
this[9] = 31;
this[10] = 30;
this[11] = 31;
}
var date = new arry();
function stopclock() {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock() {
stopclock();
showtime();
}
function showtime() {
now = new Date();
var CurMonth = now.getMonth();
var CurDate = now.getDate();
var CurYear = now.getFullYear();
now = null;
if (28 < CurDate) {
CurDate -= date[CurMonth]; CurMonth++;
}
if (5 < CurMonth) {
CurMonth -= 12; CurYear++;
}
var Yearleft = 2008 - CurYear;
var Monthleft = 5 - CurMonth;
var Dateleft = 28 - CurDate;
document.dateform.a.value = Yearleft;
document.dateform.b.value = Monthleft;
document.dateform.c.value = Dateleft;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
// End -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>倒计时</title>
</head>
<BODY Onload="startclock()">
<form name=dateform>距离6/28/2008还有
<input type=text name=a size=2 value="">年
<input type=text name=b size=2 value="">月
<input type=text name=c size=2 value="">天
</form>
</body>
</html>

这是时钟的
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>时钟</title>
</head>
<body bgcolor="#fef4d9" ONLOAD=show5()>
<span id=liveclock style=position:absolute;left:250px;top:122px;; width: 109px; height: 15px>
</span>   
<SCRIPT language=javascript>
<!--
function show5(){if(!document.layers&&!document.all)
return
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if(hours>12){dn="PM"
hours=hours-12
}if(hours==0)
hours=12
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
//change font size here to your desire
myclock="<font size='5' face='Arial'><b><font size='2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;时钟 :</font></br>"+hours+":"+minutes+":"
+seconds+" "+dn+"</b></font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("show5()",1000)
}
//>
</SCRIPT></body>
</html>
2008-04-04 10:02
小心小七
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-3
收藏
得分:0 
我就是想把两个特效加入同一个网页中
没想到...
见笑了.
烦帮帮忙
2008-04-04 10:05
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
收藏
得分:0 
那就帮你合并一下吧....
程序代码:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var Temp2;
var timerID = null;
var timerRunning = false;
function arry() {
this.length = 12;
this[0] = 31;
this[1] = 28;
this[2] = 31;
this[3] = 30;
this[4] = 31;
this[5] = 30;
this[6] = 31;
this[7] = 31;
this[8] = 30;
this[9] = 31;
this[10] = 30;
this[11] = 31;
}
var date = new arry();
function stopclock() {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock() {
stopclock();
showtime();
}
function showtime() {
now = new Date();
var CurMonth = now.getMonth();
var CurDate = now.getDate();
var CurYear = now.getFullYear();
now = null;
if (28 < CurDate) {
CurDate -= date[CurMonth]; CurMonth++;
}
if (5 < CurMonth) {
CurMonth -= 12; CurYear++;
}
var Yearleft = 2008 - CurYear;
var Monthleft = 5 - CurMonth;
var Dateleft = 28 - CurDate;
document.dateform.a.value = Yearleft;
document.dateform.b.value = Monthleft;
document.dateform.c.value = Dateleft;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}

//倒计时
function show5(){
if(!document.layers&&!document.all)
return
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if(hours>12){dn="PM"
hours=hours-12
}if(hours==0)
hours=12
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
//change font size here to your desire
myclock="<font size='5' face='Arial'><b><font size='2'>       时钟 :</font></br>"+hours+":"+minutes+":"
+seconds+" "+dn+"</b></font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("show5()",1000)
}
// End -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>倒计时</title>
</head>
<BODY Onload="startclock();show5();">
<form name=dateform>距离6/28/2008还有
<input type=text name=a size=2 value="">年
<input type=text name=b size=2 value="">月
<input type=text name=c size=2 value="">天
</form>
<span id=liveclock style=position:absolute;left:250px;top:122px;; width: 109px; height: 15px>
</span>   
</body>
</html>
2008-04-04 15:25
小心小七
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-3
收藏
得分:0 
谢谢版主的热心帮忙:)
马上去试试...
再次感谢.
2008-04-08 23:29
小心小七
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-3
收藏
得分:0 
成了,呵呵,谢谢版主.
为自已的菜而汗颜...
要是有时间
版主能不能顺便帮我扫下盲.
2008-04-11 11:01
快速回复:求助((第一回发帖)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044369 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved