站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题JavaScript 寫時鍾日曆

JavaScript 寫時鍾日曆

摘要: 日曆,日历,javascript,jscript,dewin,dwin,js
<textarea readonly style="border:none;font-family:Courier New;line-height:150%;width:760px;overflow-y:visible">

另一種日曆寫法!

效率很不錯的哦。

Copyright(c) 1998-2004 dewin all rights reserved

Start 2003-06-21 00:08
Finish 2003-06-22 02:50 Calendar
Finish 2003-06-22 15:35 Time
Finish 2003-06-22 18:55 Second Edit
Finish 2003-06-23 02:49 Last Edit
Finish 2003-06-25 10:10 emu <select>

<script>var NowTime = new Date().valueOf()</script>


<body>


<input id='iYears' style='position:absolute;left:53%;top:10%;width:33%;height:11%;overflow:hidden;font-size:9pt;border:1 solid #7F9DB9' onkeydown='if(event.keyCode==13)ShowDate(this.value,iMonths.selectedIndex)'>



<table style='position:absolute;left:0;top:0;width:100%;height:12%;color:#D8E4F8;background:#7A96DF;font-size:9pt;text-align:center'><tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr></table>

<script>
/*
for(i=0;i<6;i++)document.write(",&nbsp;")
for(i=1;i<56;i++) document.write((i+5)%13==0?"
,"+(i-6*parseInt((i+5)/13)):","+(i-6*parseInt((i+5)/13)))
*/

/* Calendar HTML start */
var iHTML=""
for(i=1;i<=31;i++){
iHTML+="<td>"+i+"</td>"
if(i%7==0)iHTML+="</tr><tr>"
}
iHTML+="</tr></table>"
document.write("<table style='position:absolute;left:0;top:17%;width:50%;height:85%;font-size:9pt;text-align:center;' cellSpacing=0><tr>"+iHTML+"<table style='position:absolute;left:50%;top:0;width:50%;height:85%;font-size:9pt;text-align:center;' cellSpacing=0><tr>"+iHTML)
/* Calendar HTML end */

DateArray = []
for(i=0;i<31;i++){//Collect days <td> to an Array
DateArray[i*2]=iCalendar.childNodes[1].rows[parseInt(i/7)].cells[i%7].firstChild
DateArray[i*2+1]=iCalendar.childNodes[2].rows[parseInt(i/7)].cells[i%7].firstChild
}
</script>


<input id='iTime' style='position:relative;top:83%;width:60%;height:10%;font-size:9pt;border:1 solid #7F9DB9;text-align:right'>

Date
Time

<script>

/* Clock HTML start */
function CalX(t,r,k){return parseInt(1+Math.sin(t*2*Math.PI/k)*r)}
function CalY(t,r,k){return parseInt(1-Math.cos(t*2*Math.PI/k)*r)}

for(i=0;i<60;i++)
if(i%5 == 0) document.write("")
else document.write("")
document.write("")
/* Clock HTML end */

setInterval(GetTime,1000)
// use the rotation to control the time object
function GetTime(){
t = new Date(NowTime+=1000)
iSecond.style.rotation = t.getSeconds()*6
iMinute.style.rotation = t.getMinutes()*6+t.getSeconds()/10
iHour.style.rotation = t.getHours()*30+t.getMinutes()/2
iTime.value = t.toLocaleString().match(/\d+:\d+/)+':'+t.getSeconds()
}
</script>


<script language="JavaScript">

function ShowDate(oYear,oMonth){
var oDays = new Date(oYear,oMonth,0).getDate()
var oFirstDay = 7-new Date(oYear,oMonth-1).getDay()
iCalendar.style.left = -iCalendar.offsetWidth*.07143*oFirstDay
for(i=0;i<6;i++) DateArray[i+56].style.visibility = (parseInt(i/2)+29>oDays)?'hidden':'visible'//29->31
iMonths.parentNode.firstChild.value = MonthsArray[oMonth-1];
if(BackDay>oDays) DayChoose(oDays)
}

var BackDay = 0

function DayChoose(objnum){
if(BackDay==objnum) return
for(i=1;i<=2;i++){
if(BackDay){
DateArray[BackDay*2-i].style.background = ''
DateArray[BackDay*2-i].style.color = 'black'
}
DateArray[objnum*2-i].style.background = '#0054E3'
DateArray[objnum*2-i].style.color = 'white'
}
BackDay = objnum
}


//document.write("&#",t.getMonth()+12992,"&#",t.getDate()+13279,"&#",t.getHours()+13144)
function window.onload(){
var t = new Date(NowTime)
iYears.value = t.getFullYear()
iMonths.selectedIndex = t.getMonth()+1
setTimeout("ShowDate("+t.getFullYear()+","+(t.getMonth()+1)+")",10)
DayChoose(t.getDate())
}


function HeightLight(){
var obj = event.srcElement
var obj2 = event.fromElement
if(obj.nodeName=="INPUT"){
obj.style.color = 'white'
obj.style.background = '#FFB0F8'
}
if(obj2.nodeName=="INPUT"){
obj2.style.color = ''
obj2.style.background = ''
}
}


window.onerror = ReturnTrue;
window.onhelp = ReturnFalse;
document.ondragstart = ReturnFalse;
document.oncontextmenu = ReturnFalse;
document.onselectstart = ReturnFalse;

function document.onkeydown(){
with(event){
if((keyCode&&(event.ctrlKey||altKey)) || (keyCode>=112 && keyCode<=123)){
keyCode = 0;
ReturnFalse();
}
}
}


function ReturnTrue(){
event.returnValue = true;
}

function ReturnFalse(){
event.returnValue = false;
}
</script>


</textarea>
↑返回目录
前一篇: 关于javascript中数组元素删除问题的讨论
后一篇: JavaScript 寫遊戲 : 搬運工