»
Tiếng AnhTiếng PhápTiếng Việt

In - Hiển thị câu chào - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Thời gian » Hiển thị câu chào
URL: https://www.javascriptbank.com/greeting-and-holiday-script.html

Hiển thị câu chào © JavaScriptBank.comĐoạn mã dựa vào thời gian trên máy tính để hiển thị câu chào vào những ngày lễ lớn.

Phiên bản đầy đủ: jsB@nk » Thời gian » Hiển thị câu chào
URL: https://www.javascriptbank.com/greeting-and-holiday-script.html



HTML
<SCRIPT language=javascript><!-- Begin Stamp = new Date(); today = new Date(); var Month; var holidaytest; var holidaygreeting; <!-- Valentine's Day //--> if (((Stamp.getMonth()+1) == 2) && (Stamp.getDate() == 14)){ holidaytest = "yes"; holidaygreeting = "<font color='#cc6699'>H</font>a<font color='#cc6699'>p</font>p<font color='#cc6699'>y</font> V<font color='#cc6699'>a</font>l<font color='#cc6699'>e</font>n<font color='#cc6699'>t</font>i<font color='#cc6699'>n</font>e<font color='#cc6699'>'</font>s <font color='#cc6699'>D</font>a<font color='#cc6699'>y</font>"; } <!-- St. Patrick's Day //--> if (((Stamp.getMonth()+1) == 3) && (Stamp.getDate() == 14)){ holidaytest = "yes"; holidaygreeting = "<font color='#99cc99'>Happy St. Patrick's Day</font>"; } <!--Easter //--> <!--Check Moon Cycles--> var currentDate = new Date(); var x = currentDate; currentDate.setTime(currentDate.getTime() + (currentDate.getTimezoneOffset()*60000)); var blueMoonDate = new Date(96, 1, 3, 16, 15, 0); var lunarPeriod = 29*(24*3600*1000) + 12*(3600*1000) + 44.05*(60*1000); var moonPhaseTime = (currentDate.getTime() - blueMoonDate.getTime()) % lunarPeriod; var time = Math.round((lunarPeriod-moonPhaseTime)/(24*3600*1000)); <!--Is it in March?--> if ((Stamp.getMonth()+1) == 3) { if ((Stamp.getDate() > 21) && (20 < time < 30)){ if ((Stamp.getDay() == 5) || (Stamp.getDay() == 6) || (Stamp.getDay() == 0)){ holidaytest = "yes"; holidaygreeting = "Happy Easter"; } } } <!--Is it in April?--> if ((Stamp.getMonth()+1) == 4) { if (Stamp.getDate() < 26){ if (20 < time < 30){ if ((Stamp.getDay() == 5) || (Stamp.getDay() == 6) || (Stamp.getDay() == 0)){ holidaytest = "yes"; holidaygreeting = "Happy Easter"; } } } } <!--Memorial Day //--> if (((Stamp.getMonth()+1) == 5) && (Stamp.getDate() > 24)){ if ((Stamp.getDay() == 6) || (Stamp.getDay() == 0) || (Stamp.getDay() == 1)){ holidaytest = "yes"; holidaygreeting = "Have a safe and happy holiday"; } } <!-- 4th of July //--> if (((Stamp.getMonth()+1) == 7) && (1 <= Stamp.getDate())){ holidaytest = "yes"; holidaygreeting = "<font color='#cc6699'>H</font>a<font color='#99ccff'>v</font><font color='#cc6699'>e</font> a <font color='#99ccff'>H</font><font color='#cc6699'>a</font>p<font color='#99ccff'>p</font><font color='#cc6699'>y</font> a<font color='#99ccff'>n</font><font color='#cc6699'>d</font> S<font color='#99ccff'>a</font><font color='#cc6699'>f</font>e <font color='#99ccff'>4</font><font color='#cc6699'>t</font>h <font color='#99ccff'>o</font><font color='#cc6699'>f</font> J<font color='#99ccff'>u</font><font color='#cc6699'>l</font>y"; } if (((Stamp.getMonth()+1) == 7) && (Stamp.getDate() >= 5)){ holidaytest = "no"; } <!--Labor Day //--> if (((Stamp.getMonth()+1) == 9) && (Stamp.getDate() < 8)){ if ((Stamp.getDay() == 6) || (Stamp.getDay() == 0) || (Stamp.getDay() == 1)){ holidaytest = "yes"; holidaygreeting = "Have a safe and happy holiday"; } } <!-- Halloween //--> if (((Stamp.getMonth()+1) == 10) && (Stamp.getDate() == 31)){ holidaytest = "yes"; holidaygreeting = "<font color='#ff8c00'>H</font><font color='#000000'>a</font><font color='#ff8c00'>p</font><font color='#000000'>p</font><font color='#ff8c00'>y</font> <font color='#000000'>H</font><font color='#ff8c00'>a</font><font color='#000000'>l</font><font color='#ff8c00'>l</font><font color='#000000'>o</font><font color='#ff8c00'>w</font><font color='#000000'>e</font><font color='#ff8c00'>e</font><font color='#000000'>n</font>"; } <!-- Thanksgiving //--> if (((Stamp.getMonth()+1) == 11) && (21 < Stamp.getDate() < 30)){ if (Stamp.getDay() == 4){ holidaytest = "yes"; holidaygreeting = "Happy Thanksgiving"; } } <!-- Christmas //--> if (((Stamp.getMonth()+1) == 12) && (10 <= Stamp.getDate())){ holidaytest = "yes"; holidaygreeting = "<font color='#ff0000'>M</font><font color='#00ff00'>e</font><font color='#ff0000'>r</font><font color='#00ff00'>r</font><font color='#ff0000'>y</font> <font color='#00ff00'>C</font><font color='#ff0000'>h</font><font color='#00ff00'>r</font><font color='#ff0000'>i</font><font color='#00ff00'>s</font><font color='#ff0000'>t</font><font color='#00ff00'>m</font><font color='#ff0000'>a</font><font color='#00ff00'>s</font>"; } if (((Stamp.getMonth()+1) == 12) && (Stamp.getDate() > 25)){ holidaytest = "no"; } <!-- New Year //--> if (((Stamp.getMonth()+1) == 12) && (Stamp.getDate() > 26)){ holidaytest = "yes"; holidaygreeting = "Happy New Year"; } if (((Stamp.getMonth()+1) == 1) && (Stamp.getDate() < 2)){ holidaytest = "no"; } if((today.getHours() >=0) && (today.getHours() <=11)){ if (holidaytest == "yes"){ document.write(holidaygreeting); } else{ document.write("Good Morning"); } } if((today.getHours() >=12) && (today.getHours() <=16)){ if (holidaytest == "yes"){ document.write(holidaygreeting); } else{ document.write("Good Afternoon"); } } if((today.getHours() >=17) && (today.getHours() <=23)){ if (holidaytest == "yes"){ document.write(holidaygreeting); } else{ document.write("Good Evening"); } } // End --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->