国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Javascript做的倒計(jì)時(shí)時(shí)鐘代碼實(shí)例
 
Javascript做的倒計(jì)時(shí)時(shí)鐘代碼實(shí)例
 
js文件------countdown.js

var test_val; //聲明變量
function el(id) {
   if (document.getElementById) {
     return document.getElementById(id);
   } else if (window[id]) {
     return window[id];
   }
   return null;
}

function UpdateDisplay()
{
    document.tform1.ctd.value = GetCountdownTime(document.tform1.cs.value);
    document.tform2.ctd.value = GetCountdownTime(document.tform2.cs.value);
    document.tform3.ctd.value = GetCountdownTime(document.tform3.cs.value);
    document.tform4.ctd.value = GetCountdownTime(document.tform4.cs.value);

    test_val = el("test_val")
    test_val.innerHTML = GetCountdownTime(document.tform4.cs.value);

    timer1=setTimeout(’UpdateDisplay()’,250);
}

function GetCountdownTime(date_str)
{
    return( TimeToHMS( GetSecond( new Date(date_str))));   
}

/* get the countdown initial time to a specific time */
function GetSecond(date_count_to)
{
    date_now = new Date();
   
    time_now = date_now.getTime();
    time_count_to = date_count_to.getTime();

    if(time_now >= time_count_to )
    {
       ret_val = 0;
    }
    else
    {
       ret_val = Math.round( ( time_count_to - time_now ) / 1000.0 );
    }
   
    return (ret_val);
}

/* convert seconds value to H:MM:SS format */
function TimeToHMS(seconds)
{
    sec = seconds % 60;
    temp = ( seconds - sec ) / 60;
   
    minute = temp % 60;
    hour = (temp - minute) / 60;
   
    if(!(isFinite(sec) && isFinite(minute) && isFinite(hour))) /* invalid time */
    {
       return ("");
    }
   
    time_str = hour;
    time_str += ":";   
    time_str+=(minute<10)?("0"+minute):minute;
    time_str+=":";
    time_str+=(sec<10)?("0"+sec):sec;
   
    return (time_str);
}


測(cè)試文件:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
<title>Test the countdown function</title>

<! include the javascript file >
<script language="JavaScript" src="countdown.js" type="text/JavaScript"><!--
//--></script>

</head>
<body>


Test1: <span id="timer1"></span><br>

<script>
<!--
var timer1;
var time_val1=6000;

function updateTimer1()
{
    timer1 = el("timer1")
    timer1.innerHTML = TimeToHMS(time_val1);
    time_val1--;

    setTimeout(’updateTimer1()’, 1000);
}

updateTimer1();
// -->
</script>

Test2: <span id="timer2"></span><br>

<script>
<!--
var timer2;
var time_val2=66000;

function updateTimer2()
{
    timer2 = el("timer2")
    timer2.innerHTML = TimeToHMS(time_val2);
    time_val2--;

    setTimeout(’updateTimer2()’, 1000);
}

updateTimer2();
// -->
</script>

Test1000: <span id="timer1000">ii</span><br>
<script><!--
var timer1000;
var time_val1000=78900;
function updateTimer1000(){
timer1000 = el("timer1000");
timer1000.innerHTML = TimeToHMS(time_val1000);
time_val1000--;
setTimeout(’updateTimer1000()’, 1000);}
updateTimer1000();
// -->
</script>

</body>
</html> countdown.js

var test_val;

function el(id) {
   if (document.getElementById) {
     return document.getElementById(id);
   } else if (window[id]) {
     return window[id];
   }
   return null;
}

function UpdateDisplay()
{
    document.tform1.ctd.value = GetCountdownTime(document.tform1.cs.value);
    document.tform2.ctd.value = GetCountdownTime(document.tform2.cs.value);
    document.tform3.ctd.value = GetCountdownTime(document.tform3.cs.value);
    document.tform4.ctd.value = GetCountdownTime(document.tform4.cs.value);

    test_val = el("test_val")
    test_val.innerHTML = GetCountdownTime(document.tform4.cs.value);

    timer1=setTimeout(’UpdateDisplay()’,250);
}

function GetCountdownTime(date_str)
{
    return( TimeToHMS( GetSecond( new Date(date_str))));   
}

/* get the countdown initial time to a specific time */
function GetSecond(date_count_to)
{
    date_now = new Date();
   
    time_now = date_now.getTime();
    time_count_to = date_count_to.getTime();

    if(time_now >= time_count_to )
    {
       ret_val = 0;
    }
    else
    {
       ret_val = Math.round( ( time_count_to - time_now ) / 1000.0 );
    }
   
    return (ret_val);
}

/* convert seconds value to H:MM:SS format */
function TimeToHMS(seconds)
{
    sec = seconds % 60;
    temp = ( seconds - sec ) / 60;
   
    minute = temp % 60;
    hour = (temp - minute) / 60;
   
    if(!(isFinite(sec) && isFinite(minute) && isFinite(hour))) /* invalid time */
    {
       return ("");
    }
   
    time_str = hour;
    time_str += ":";   
    time_str+=(minute<10)?("0"+minute):minute;
    time_str+=":";
    time_str+=(sec<10)?("0"+sec):sec;
   
    return (time_str);
}


測(cè)試文件:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
<title>Test the countdown function</title>

<! include the javascript file >
<script language="JavaScript" src="countdown.js" type="text/JavaScript"><!--
//--></script>

</head>
<body>


Test1: <span id="timer1"></span><br>

<script>
<!--
var timer1;
var time_val1=6000;

function updateTimer1()
{
    timer1 = el("timer1")
    timer1.innerHTML = TimeToHMS(time_val1);
    time_val1--;

    setTimeout(’updateTimer1()’, 1000);
}

updateTimer1();
// -->
</script>

Test2: <span id="timer2"></span><br>

<script>
<!--
var timer2;
var time_val2=66000;

function updateTimer2()
{
    timer2 = el("timer2")
    timer2.innerHTML = TimeToHMS(time_val2);
    time_val2--;

    setTimeout(’updateTimer2()’, 1000);
}

updateTimer2();
// -->
</script>

Test1000: <span id="timer1000">ii</span><br>
<script><!--
var timer1000;
var time_val1000=78900;
function updateTimer1000(){
timer1000 = el("timer1000");
timer1000.innerHTML = TimeToHMS(time_val1000);
time_val1000--;
setTimeout(’updateTimer1000()’, 1000);}
updateTimer1000();
// -->
</script>

</body>
</html>
 
 
 
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
關(guān)于顯示透空歌詞的思路
常用作帖、發(fā)帖代碼集萃
WinAPI: WindowFromPoint- 獲取指定點(diǎn)所在窗口的句柄 - 萬(wàn)一的 Delphi 博客 - 博客園
delphi創(chuàng)建和讀取xml(xml簡(jiǎn)單操作舉例)
Delphi自動(dòng)檢測(cè)U盤插入
Delphi多線程編程 - 編程技巧文章 - 藍(lán)鳥軟件-03
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服