HTML网页文件显示时间代码和倒计时代码

更新时间:2023-05-18 17:21:50 阅读: 评论:0

网页显示时间代码和倒计时代码大全:
<SCRIPT language=JavaScript>
var enabled = 0;  today = new Date();
var day;  var date;
Day()==0)    day = "星期日"
Day()==1)    day = "星期一"
Day()==2)    day = "星期二"
Day()==3)    day = "星期三"
Day()==4)    day = "星期四"
Day()==5)    day = "星期五"
Day()==6)    day = "星期六"
document.fgColor = " cadet";
date1 = "<font size=5 face=宋体 color=0000ff>" + (Year()) + "年" + (Month() + 1 ) + "月" + Date() + "日 " + "</font>";
date2 = "<font size=5 face=宋体 color=ff0000>" + day + "</font>";
document.write("<center>" + date1.fontsize(2) + date2.fontsize(2) + "</center>");
</SCRIPT>
<P class=t_msgfont align=center><BR><SPAN id=liveclock 15px? height: 109px; style?="width:"><FONT color=#ff0f00 size=5>17:47:26</FONT></SPAN>
<SCRIPT language=javascript>
function www_11qiyi_com()
{
var Digital=new Date()
var Hours()
var Minutes()
var Seconds()
if(minutes<=9)
minutes="0"+minutes
if(conds<=9)
conds="0"+conds
myclock="<font size=5 color=0000ff>"+hours+":"+minutes+":"+conds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.clo()
}el if(document.all)
liveclock.innerHTML=myclock
tTimeout("www_11qiyi_com()",1000)
}
www_11qiyi_com();
磁带转录
//-->
</SCRIPT>
中文显示的时候保存为.js文件再用网页调用出现乱码。用uft-8编码保存.js文件即可解决乱码问题。
---------------------------------------------------------分割线-----------------------------------------------------
实时游走的数字时钟
<script>
function tick() {
var hours, minutes, conds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = Hours();
intMinutes = Minutes();
intSeconds = Seconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} el if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} el if (intHours == 12) {
hours = "12:";
xfile = "正午";
} el {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} el {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
conds = "0"+intSeconds+" ";
} el {
conds = intSeconds+" ";
}
timeString = xfile+hours+minutes+conds;
Clock.innerHTML = timeString;
window.tTimeout("tick();", 100);
}
</script>
第1步.将下面的代码加入html文件任意需要的地方
<div id="Clock" align="center" ></div>
你可以自行更改样式!
 ---------------------------------------------------------分割线--------------------------------------
---------------
显示年月日格式的时间代码
<script language=javascript>
too badtoday=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font color=##000000 style='font-size:9pt;font-family: 宋体'> ",
Day()+1],
"</font>" );
</script>
 ---------------------------------------------------------分割线-----------------------------------------------------
显示日期,星期,时间格式的代码
<script language="javascript">
<!---
today=new Date();
var hours = Hours();
var minutes = Minutes();
var conds = Seconds();
var timevalue = "<FONT COLOR=black>" + ((hours >12) ? hours -12 :hours); timevalue += ((minutes < 10) ? "<BLINK>
<FONT COLOR=black>:</FONT></BLINK>0" : "<BLINK><FONT COLOR=black>:</FONT></BLINK>") + minutes+"</FONT></FONT>";
timevalue += (hours >= 12) ? "<FONT COLOR=blue><I><B>pm</B></I></FONT>" : "<FONT COLO
R=blue><B><I>am</I></B></FONT>";
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray("& lt;font color=RED>星期日","<font color=black>星期一","< font color=black>星期二","<font color=black>星期
三","<font color=black>星期四","<font color=black>星期五","<font color=red>星期六"); document.write
("<font color=black>",Year(),"<font color=black> 年","<font color=black>",Month()+1,"<font color=black>
月","<font color=black>",Date(),"<font color=black>日 </FONT>",Day()+1]," ",timevalue); //-->
</script>
---------------------------------------------------------分割线-----------------------------------------------------
显示来访者的停留时间
<script language="javascript">
var ap_name = navigator.appName;
var ap_vinfo = navigator.appVersion;
var ap_ver = parFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));
var time_start = new Date();
var clock_start = Time();
var dl_ok=fal;
function init ()
{
if(ap_name=="Netscape" && ap_ver>=3.0)
dl_ok=true;
return true;
}
function get_time_spent ()
{
var time_now = new Date();
namerichreturn((Time() - clock_start)/1000);
}
function show_cs () // show the time ur spent on the side
{
var i_total_cs = und(get_time_spent());
var i_cs_spent = i_total_cs % 60;
var i_mins_spent = und((i_total_cs-30)/60);
var s_cs_spent = "" + ((i_cs_spent>9) ? i_cs_spent : "0" + i_cs_spent);
var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);
document.fm0.time_spent.value = s_mins_spent + ":" + s_cs_spent;
window.tTimeout('
show_cs()',1000);
}
// -->
</script>
<FORM name="fm0" onSubmit="0"><FONT COLOR="#6060FF">停留时间:
</FONT><INPUT type="text" name="time_spent" size=7 onFocus="this.blur()"></FORM>
第二步:在你主页源文件<body>中加入下面代码的兰色部分
<BODY onLoad="init(); window.tTimeout('show_cs()',1);">
---------------------------------------------------------分割线----------------------------------------------------- 
显示当前日期与时间的格式
<script language="javascript">
<!--
now = new Date()
hour = Hours()
if (hour < 12) {
document.write("现在是: " + LocaleString())
} el if (hour < 18){
document.write("现在是: " + LocaleString())
} el if (hour >= 18) {
document.write("现在是: " + LocaleString())
}
// --></script>
---------------------------------------------------------分割线----------------------------------------------------- 
浏览器状态栏显示的时钟
<BODY onLoad="run(); timerONE=window.tTimeout"></BODY>
<SCRIPT LANGUAGE="javascript">
<!-- Hide
timeID = null;
timeRunning = fal;
function stop () {
if(timeRunning)
clearTimeout(timeID);
timeRunning = fal;
高口报名}
function time () {
tick = new Date();
how to learn english 作文hours = Hours();
minutes = Minutes();
conds = Seconds();
day = Day();
month = Month();
date = Date();
year = Year();
current = "" + ((hours >12) ? hours -12 :hours)
current += ((minutes < 10) ? ":0" : ":") + minutes
current += ((conds < 10) ? ":0" : ":") + conds
current += (hours >= 12) ? " P.M." : " A.M."
if(day==0){var weekday = " 星期日"}
if(day==1){var weekday = " 星期一"}
if(day==2){var weekday = " 星期二"}
if(day==3){var weekday = " 星期三"}
if(day==4){var weekday = " 星期四"}
if(day==5){var weekday = " 星期五"}
if(day==6){var weekday = " 星期六"}
current +=(weekday)
window.status=current;
timeID = tTimeout("time()",1000);
timeRunning = true;
}
function run(){
stop();
time();
}
//-->
</SCRIPT>
---------------------------------------------------------分割线----------------------------------------------------- 
显示最后更新时间代码
<SCRIPT language=javascript>
<!--hide script from old browrs
document.write("最后更新时间: " + document.lastModified + "")
// end hiding -->
</SCRIPT>
---------------------------------------------------------分割线-----------------------------------------------------
实时走动的数字时钟
<script>
function tick() {
var hours, minutes, conds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = Hours();
intMinutes = Minutes();
intSeconds = Seconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} el if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} el if (intHours == 12) {
hours = "12:";
xfile = "正午";
} el {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} el {
minutes = intMinutes+":";
}2015年高考语文试卷
if (intSeconds < 10) {
conds = "0"+intSeconds+" ";
} el {
conds = intSeconds+" ";
}
timeString = xfile+hours+minutes+conds;
Clock.innerHTML = timeString;
window.tTimeout("tick();", 100);
}
</script>
<div id="Clock" ></div>
 ---------------------------------------------------------分割线-----------------------------------------------------
根据不同的时间显示不同的问候语
方法:在主页中你需要的地方加入以下代码:
<script language="LiveScript">
now = new Date(),hour = Hours()
if(hour < 6){document.write("明天不用上班了吗?")}
el if (hour < 8){document.write("全新的一天!")}
el if (hour < 12){document.write("早安!")}
el if (hour < 14){document.write("外面太阳大吗?")}
el if (hour < 18){document.write("午安!")}
el if (hour < 22){document.write("晚上好!")}
el if (hour < 24){document.write("夜深了! 要注意身体呀! 祝你做个好梦!")}
// -->
</script>
说明,可以自行修改出更好更多的问候语!
 ---------------------------------------------------------分割线-----------------------------------------------------
一个很酷的透明时钟代码
方法:在页面中你需要的地方加入下面的代码
<STYLE type=text/css>
BODY {COLOR: #000000; FONT-FAMILY: "宋体"; FONT-SIZE: 9pt; LINE-HEIGHT: 13pt}
TD {COLOR: #000000; FONT-FAMILY: "宋体"; FONT-SIZE: 9pt; LINE-HEIGHT: 13pt}
A:visited {COLOR: #000080;text-decoration:none}
a:link { text-decoration:none }
a:hover { text-decoration:underline }
.f12 {font-size:12px;}
.f13 {font-size:14.9px; LINE-HEIGHT: 120%}
.f24 {font-size:24px;LINE-HEIGHT: 120%}
.f14 {font-size:14.9px; LINE-HEIGHT: 170%}
</STYLE>
<script LANGUAGE="javascript">
Zp=670;H='....';H=H.split('');M='.....';M=M.split('');S='......';S=S.split('');Yp=0;Xp=0;Yb=8;Xb=8;d_=12;
ns=(document.layers)?1:0;fCol='222222';sCol='ff0000';mCol='0000ee';hCol='green';if (ns){dgts='1 2 3 4 5 6 7 8 9 10 11 12';
dgts=dgts.split(' ');for (i=0;i<d_;i++){document.write('<layer name=nsDigits'+i+' top=0 left=0 height=30 width=30>
<center><font face=Arial,Verdana size=1 color='+fCol+'>'+dgts[i]+'</font></center></layer>');}for (i=0;i<M.length;i++)
{document.write('<layer name=ny'+i+' top=0 left=0 bgcolor='+mCol+' clip="0,0,2,2"></layer>');}for (i=0;i<H.length;i++)
{document.write('<layer name=nz'+i+' top=0 left=0 bgcolor='+hCol+' clip="0,0,2,2"></layer>');}for (i=0;i<S.length;i++)
{document.write('<layer name=nx'+i+' top=0 left=0 bgcolor='+sCol+' clip="0,0,2,2"></layer>');}}el{document.write('
<div ><div >');for (i=1;i<d_+1;i++){document.write
('<div id="ieDigits"
style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial,Verdana;font-size:
10px;color:'+fCol+';text-align:center;padding-top:10px">'+i+'</div>');}document.write('</div></div>');document.write
('<div ><div >');for (i=0;i<M.length;i++){document.write
厦门新航道
('<div id=y ></div>');}document.write('</div>
</div>');document.write('</div></div>');document.write('<div >
<div >');for (i=0;i<H.length;i++){document.write
('<div id=z ></div>');}document.write('</div>
</div>');document.write('<div ><div >');for (i=0;i
<S.length;i++){document.write('<div id=x >
</div>');}document.write('</div></div>');}function clock(){time=new Date ();Seconds();c=-1.57+Math.PI*cs/
30;Minutes();min=-1.57+Math.PI*mins/30;Hours();hrs=-1.57+Math.PI*hr/6+Math.PI*Minutes
())/360;if (ns){Yp=window.pageYOfft+window.innerHeight-60;Xp=80;}el
{Yp=document.body.scrollTop+window.document.body.clientHeight-60;Xp=document.body.scrollLeft+60;}if (ns){for (i=0;i<d_;++i)
{document.layers["nsDigits"+i].top=Yp-5+40*Math.sin(-0.49+d_+i/1.9);document.layers["nsDigits"+i].left=Xp-15+s(-0.49
+d_+i/1.9);}for (i=0;i<S.length;i++){document.layers["nx"+i].top=Yp+i*Yb*Math.sin(c);document.layers
["nx"+i].left=Xp+i*s(c);}for (i=0;i<M.length;i++){document.layers["ny"+i].top=Yp+i*Yb*Math.sin(min);document.layers
["ny"+i].left=Xp+i*s(min);}for (i=0;i<H.length;i++){document.layers["nz"+i].top=Yp+i*Yb*Math.sin(hrs);document.layers
["nz"+i].left=Xp+i*s(hrs);}}el{for (i=0;i<d_;++i){ieDigits[i].style.pixelTop=Yp-15+40*Math.sin(-0.49+d_+i/
1.9);ieDigits[i].style.pixelLeft=Xp-14+s(-0.49+d_+i/1.9)+Zp;}for (i=0;i<S.length;i++){x
[i].style.pixelTop=Yp+i*Yb*Math.sin(c);x[i].style.pixelLeft=Xp+i*s(c)+Zp;}for (i=0;i<M.length;i++){y
[i].style.pixelTop=Yp+i*Yb*Math.sin(min);y[i].style.pixelLeft=Xp+i*s(min)+Zp;}for (i=0;i<H.length;i++){z
[i].style.pixelTop=Yp+i*Yb*Math.sin(hrs);z[i].style.pixelLeft=Xp+i*s(hrs)+Zp;}}tTimeout('clock()', 50);}
if (document.layers || document.all) {load=clock;}
</script>
---------------------------------------------------------分割线-----------------------------------------------------
形如今天是2008年8月27日,星期三的代码
<script>
var mydate=new Date()
var Year()
if (year < 1000)
year+=1900
var Day()
var Month()
globalizedvar
Date()
if (daym<10)
daym="0"+daym
var dayarray=new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六")
var montharray=new Array("1","2","3","4","5","6","7","8","9","10","11","12")
document.write("今天是"+year+"年"+montharray[month]+"月"+daym+"日"+","+dayarray[day])
</script>
---------------------------------------------------------分割线-----------------------------------------------------
实时倒计时代码,可以设定期限!
<!--单位:秒-->
剩余时间:<span id="endtime">10</span>
<script type="text/javascript">
var CID = "endtime";
if(window.CID != null)
{
var iTime = ElementById(CID).innerText;
var Account;
RemainTime();
}
function RemainTime()
{
var iDay,iHour,iMinute,iSecond;
var sDay="",sHour="",sMinute="",sSecond="",sTime="";
if (iTime >= 0)
{
iDay = parInt(iTime/24/3600);
if (iDay > 0)
{
sDay = iDay + "天";
}
iHour = parInt((iTime/3600)%24);
if (iHour > 0){
sHour = iHour + "小时";
}
iMinute = parInt((iTime/60)%60);
if (iMinute > 0){
sMinute = iMinute + "分钟";
}
iSecond = parInt(iTime%60);
if (iSecond >= 0){
sSecond = iSecond + "秒";
}
if ((sDay=="")&&(sHour=="")){
sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
鬼把戏}
el
{
sTime=sDay+sHour+sMinute+sSecond;
}
if(iTime==0){
clearTimeout(Account);
sTime="<span style='color:green'>时间到了!</span>";
}
el
{
Account = tTimeout("RemainTime()",1000);thl
}
iTime=iTime-1;
}
el
{
sTime="<span style='color:red'>倒计时结束!</span>";
}
}
</script>
</body>
</html>

本文发布于:2023-05-18 17:21:50,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/113542.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:代码   显示   时间
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图