mafia10th โพสต์ 2010-12-2 17:33:47

สคริป เค้าท์ดาวน์ สู่วันปีใหม่! {อัพเดตอันใหม่}

แก้ไขครั้งสุดท้ายโดย mafia10th เมื่อ 2010-12-9 15:11

แก้ไขครั้งสุดท้ายโดย mafia10th เมื่อ 2010-12-9 12:28 ตัวอย่าง : http://vongola-th.net**เอาไปใส่ได้ทุกที่ครับ!<center><script language="JavaScript">
TargetDate = "12/31/2010 00:00 AM";
BackColor = "#CCCC99";
ForeColor = "black";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "อีกแค่ %%D%% วัน, %%H%% ชั่วโมง, %%M%% นาที, %%S%% วินาทีก็ปีใหม่แล้ว!";
FinishMessage = "Happy New Year 2011!! สวัสดีปีใหม่ 2554";


function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
    s = "0" + s;
return "<b>" + s + "</b>";
}

function CountBack(secs) {
if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
document.write("<span id='cntdwn' style='background-color:" + backcolor +
                "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);

</script></center>

por201502 โพสต์ 2010-12-3 17:41:52

sm946dzขอบคุงครับ

kaiaoo โพสต์ 2010-12-3 21:28:06

ขอบคุณๆๆๆๆ

groufie โพสต์ 2010-12-4 08:47:02

แจ่มครับ ขอบคุณมาก

trafalgar โพสต์ 2010-12-4 15:43:20

อยากเห็ฌนตัวอย่างก่อน sm954dz

•Anime• โพสต์ 2010-12-6 19:47:31

เอาไปประยุกษ์ ได้ทุกวันเลยนะเนี่ย

mafia10th โพสต์ 2010-12-9 12:34:11

อัพเดตตัส เค้าท์ดาวน์ตัวใหม่ครับ ไฉไล กว่าเดิม

hackerth โพสต์ 2010-12-9 18:47:07

แก้ไขครั้งสุดท้ายโดย hackerth เมื่อ 2010-12-9 18:47

<HTML>
<title> Count Down 2011 </title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<BODY>
<div style="text-align:center;margin-bottom:10px;padding:10px;font:12px/1.5 Tahoma,Helvetica,mingliu,sans-serif;">

<?php
date_default_timezone_set("asia/bangkok");
$time = date("m/d/Y h:i:s A");
?>

<script language="JavaScript">
TargetDate = "1/1/2011 00:00 AM";       
SetDate = ("<?= $time ?>");
ForeColor = "#666666";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "<font color=#669900> เค้าท์ดาวน์ </font> :วันปีใหม่ 2011 เหลืออีก :<font color=#669900> %%D%%</font> วัน<font color=#669900> %%H%%</font> ชั่วโมง<font color=#669900> %%M%%</font> นาที<font color=#669900> %%S%% </font>วินาที !";
FinishMessage = "<font color=#669900>Happy New Year 2011 !</font>";


function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
    s = "0" + s;
return "<b>" + s + "</b>";
}

function CountBack(secs) {
if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
document.write("<span id='cntdwn' style='background-color:" + backcolor +
                "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date(SetDate);
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);

</script>
</div>

</BODY>
</HTML>ของผมเป็น PHP ดึงเวลาจาก Server นะครับบางคนนาฬิกาไม่ตรงเพราะ Java script มันจะดึงจากเครื่องแค่อะนนี้ผม fix ให้กำหนดเวลาของ server [เป็น PHP นะครับ Iframe ดึงเข้าไปใช้เอาครับ หรือใครจะทำเป็น DIY มาแจกก็เต็มที่ครับ >,.<]

pongpen โพสต์ 2010-12-10 00:50:38

ขอบคุณมากๆครับ
แต่ของคุณ hackerth ผมลองมันแสดงเป็น NanวันNanชั่วโมงNanนาทีNanวินาที อะครับมันไม่โผล่ตัวเลข

rocketeer โพสต์ 2010-12-15 11:32:16

เยี่ยมครับเอาไปลองแล้วhttp://ideagood.net/rocketeercafe/forum.php
หน้า: [1] 2
ดูในรูปแบบกติ: สคริป เค้าท์ดาวน์ สู่วันปีใหม่! {อัพเดตอันใหม่}