河南鄭州企業網站建設網絡公司多爾福科技
服務熱線:0371-60999820
15238075082
網頁顯示時間代碼和倒計時代碼大全
網頁顯示時間代碼和倒計時代碼大全:

<SCRIPT language=JavaScript>
   var enabled = 0;   today = new Date();
   var day;   var date;
   if(today.getDay()==0)     day = "星期日"
   if(today.getDay()==1)     day = "星期一"
   if(today.getDay()==2)     day = "星期二"
   if(today.getDay()==3)     day = "星期三"
   if(today.getDay()==4)     day = "星期四"
   if(today.getDay()==5)     day = "星期五"
   if(today.getDay()==6)     day = "星期六"
   document.fgColor = " cadet";
   date1 = "<font size=5 face=宋體 color=0000ff>" + (today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " + "</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_helpor_net()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="<font size=5 color=0000ff>"+hours+":"+minutes+":"+seconds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>


中文顯示的時候保存為.js文件再用網頁調用出現亂碼。用uft-8編碼保存.js文件即可解決亂碼問題。

------------------------------------------------------分割線-----------------------------------------------------

實時游走的數字時鐘

<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) { 
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
timeString = xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>

第1步.將下面的代碼加入html文件任意需要的地方

<div id="Clock" align="center" style="font-size: 20; color:#000000"></div>

你可以自行更改樣式!

-------------------------------------------------------分割線-----------------------------------------------------

顯示年月日格式的時間代碼

<script language=javascript>
today=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: 宋體'> ",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
d[today.getDay()+1],
"</font>" );

</script>

-------------------------------------------------------分割線-----------------------------------------------------

顯示日期,星期,時間格式的代碼

<script language="javascript"> 
<!---
today=new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
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 COLOR=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>",today.getYear(),"<font color=black> 年","<font color=black>",today.getMonth()+1,"<font color=black>

月","<font color=black>",today.getDate(),"<font color=black>日 </FONT>",d[today.getDay()+1]," ",timevalue); //-->
</script>

------------------------------------------------------分割線-----------------------------------------------------

顯示來訪者的停留時間

<script language="javascript">
var ap_name = navigator.appName;
var ap_vinfo = navigator.appVersion;
var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));

var time_start = new Date();
var clock_start = time_start.getTime();
var dl_ok=false;

function init ()
{
if(ap_name=="Netscape" && ap_ver>=3.0)
dl_ok=true; 
return true;
}

function get_time_spent ()
var time_now = new Date();
return((time_now.getTime() - clock_start)/1000); 
}

function show_secs () // show the time user spent on the side
var i_total_secs = Math.round(get_time_spent()); 
var i_secs_spent = i_total_secs % 60;
var i_mins_spent = Math.round((i_total_secs-30)/60); 
var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_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_secs_spent;
window.setTimeout('show_secs()',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.setTimeout('show_secs()',1);">

------------------------------------------------------分割線----------------------------------------------------- 

顯示當前日期與時間的格式

<script language="javascript">
<!--
now = new Date()
hour = now.getHours()
if (hour < 12) {
document.write("現在是: " + now.toLocaleString())
} else if (hour < 18){
document.write("現在是: " + now.toLocaleString())
} else if (hour >= 18) {
document.write("現在是: " + now.toLocaleString())
}
// --></script>

------------------------------------------------------分割線----------------------------------------------------- 

瀏覽器狀態欄顯示的時鐘 
<BODY onLoad="run(); timerONE=window.setTimeout"></BODY>
<SCRIPT LANGUAGE="javascript">
<!-- Hide
timeID = null;
timeRunning = false;
function stop () {
if(timeRunning)
clearTimeout(timeID);
timeRunning = false;
}
function time () {
tick = new Date();
hours = tick.getHours();
minutes = tick.getMinutes();
seconds = tick.getSeconds();
day = tick.getDay();
month = tick.getMonth();
date = tick.getDate();
year = tick.getYear();
current = "" + ((hours >12) ? hours -12 :hours)
current += ((minutes < 10) ? ":0" : ":") + minutes
current += ((seconds < 10) ? ":0" : ":") + seconds
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 = setTimeout("time()",1000);
timeRunning = true;
}
function run(){
stop();
time();
}

//-->
</SCRIPT>

------------------------------------------------------分割線----------------------------------------------------- 

顯示最后更新時間代碼

<SCRIPT language=javascript>
<!--hide script from old browsers
document.write("最后更新時間: " + document.lastModified + "")
// end hiding -->
</SCRIPT>


------------------------------------------------------分割線-----------------------------------------------------

實時走動的數字時鐘 
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) { 
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
timeString = xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>

<div id="Clock" style="font-size: 20; color:#000000"></div>

-------------------------------------------------------分割線-----------------------------------------------------

根據不同的時間顯示不同的問候語 
方法:在主頁中你需要的地方加入以下代碼:

<script language="LiveScript">
now = new Date(),hour = now.getHours()
if(hour < 6){document.write("明天不用上班了嗎?")}
else if (hour < 8){document.write("全新的一天!")}
else if (hour < 12){document.write("早安!")}
else if (hour < 14){document.write("外面太陽大嗎?")}
else if (hour < 18){document.write("午安!")}
else if (hour < 22){document.write("晚上好!")}
else if (hour < 24){document.write("夜深了! 要注意身體呀! 祝你做個好夢!")}
// -->
</script>

說明,可以自行修改出更好更多的問候語!


------------------------------------------------------分割線-----------------------------------------------------
形如今天是2008年8月27日,星期三的代碼

<script>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
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 = document.getElementById(CID).innerText;
    var Account;
    RemainTime();
}
function RemainTime()
{
    var iDay,iHour,iMinute,iSecond;
    var sDay="",sHour="",sMinute="",sSecond="",sTime="";
    if (iTime >= 0)
    {
        iDay = parseInt(iTime/24/3600);
        if (iDay > 0)
        {
            sDay = iDay + "天";
        }
        iHour = parseInt((iTime/3600)%24);
        if (iHour > 0){
            sHour = iHour + "小時";
        }
        iMinute = parseInt((iTime/60)%60);
        if (iMinute > 0){
            sMinute = iMinute + "分鐘";
        }
        iSecond = parseInt(iTime%60);
        if (iSecond >= 0){
            sSecond = iSecond + "秒";
        }
        if ((sDay=="")&&(sHour=="")){
            sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
        }
        else
        {
            sTime=sDay+sHour+sMinute+sSecond;
        }
        if(iTime==0){
            clearTimeout(Account);
              sTime="<span style='color:green'>時間到了!</span>";
        }
        else
        {
            Account = setTimeout("RemainTime()",1000);
        }
        iTime=iTime-1;
    }
    else
    {
            sTime="<span style='color:red'>倒計時結束!</span>";
    }
    document.getElementById(CID).innerHTML = sTime;
}
</script>
</body>
</html>
上一篇: 在網頁中加入視頻文件 下一篇: 截取字符串并限制字符串長度,多于給定的長度+。。。
網站首頁 | 關于我們 | 版權所有 | 網站地圖 | 服務項目 | 網站建設 | 網站優化 | 軟件開發 | 經典案例 | 常見問題 | 聯系我們
版權所有:河南多爾福電子科技有限公司 豫ICP17014991號-2 技術支持:多爾福科技
地址:河南省鄭州市鄭東新區東風南路萬通街英地金臺府邸4號樓2單元1204室。 手機:15238075082 Email:[email protected]
财富发发电子 M5彩票app地址大全 北单比分直播体育有料 自己买两只品种猫养殖能赚钱吗 贵州快三开奖走势图表 nba比分博彩qiutan 2012奥运即时比分 腾讯云起书院赚钱吗 排列5 北京pk10手机投注中心 发布资料赚钱 3D 上海快三官方开奖 棋牌娱乐大厅app 新浪体育cba 真钱和假钱的区别图片 河北十一选五跨度