几个日期特效的代码

[ 2007-11-30 15:32:58 | 作者: Admin ] 字号: | |
很实用.做网页时用的上.

1,关于星期几
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body bgcolor="#FFFFFF" text="#000000">
<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 = "星期六"

date = "<font class f7 color='#000000'> " + (today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " + day + "</font>";

document.write(date.fontsize(2)+"");

-->

</script>
</body>
</html>
<script>
quote=new Array(7)
quote[0]="天"
quote[1]="一"
quote[2]="二"
quote[3]="三"
quote[4]="四"
quote[5]="五"
quote[6]="六"
var Day_of_Week=new Date()
Quote_of_Day=Day_of_Week.getDay()
document.write("今天是星期" + quote[Quote_of_Day] + ",活活")
</script>
<script>
alert("今天是星期"+new Array("天","一","二","三","四","五","六").toString().split(",")[new Date().getDay()])
</script>
<script>
alert("今天是星期"+["天","一","二","三","四","五","六"][new Date().getDay()])
</script>
<script>
Date.prototype.getChineseDay = function ()
{
return "天一二三四五六".charAt(this.getDay())
}

alert("星期" + new Date().getChineseDay())
</script>
<script>
alert("今天是星期"+"天一二三四五六".charAt(new Date().getDay()))
</script>
<script language=vbs>
alert(WeekdayName(Weekday(NOW)))
</script>

关于第几周
<script>
var nowdate=new Date();
var nowyear=nowdate.getYear();
var tempdate= new Date(nowyear,0,1);
var min=nowdate.getTime();
var tempmin=tempdate.getTime();
var tempweekday=tempdate.getDay();
var week_num=((min-tempmin)/86400000+tempweekday)/7+1;
alert("第"+parseInt(week_num)+"周");
</script>
<script>
var day_list = new Array(31,28,31,30,31,30,31,31,10,31,30,31);
var days = (new Date()).getDate();
var this_month = (new Date()).getMonth();
for(I=0;I<=this_month;I++) days +=day_list[I];
alert("第"+parseInt(days/7)+"周");
</script>
<script>
function test(date)
{
var nowdate=new Date(date);
var nowyear=nowdate.getYear();
var tempdate= new Date(nowyear,0,1);
var min=nowdate.getTime();
var tempmin=tempdate.getTime();
var tempweekday=tempdate.getDay();
var week_num=((min-tempmin)/86400000+tempweekday)/7+1;
alert("第"+parseInt(week_num)+"周");
}

test("2000/12/31")
test("2002/12/31")
test("2003/1/5")
test("2003/1/6")
</script>
<script>
function test(date)
{
var nowdate=new Date(date);
var nowyear=nowdate.getYear();
var tempdate= new Date(nowyear,0,1);
var min=nowdate.getTime();
var tempmin=tempdate.getTime();
var tempweekday=tempdate.getDay();
var week_num=((min-tempmin)/86400000+tempweekday-1)/7;
alert("第"+parseInt(week_num)+"周");
}

test("2000/12/31")
test("2002/12/31")
test("2003/1/5")
test("2003/1/6")
</script>
<script>
alert(new Date(2003,0,5).getWeekly())
alert(new Date().getWeekly())

function Date.prototype.getWeekly(){
var oY=this.getFullYear()
var oM=this.getMonth()
var oD=this.getDate()
return 1+(new Date(oY,oM,oD-new Date(oY,oM,oD).getDay())-new Date(oY,0,7-new Date(oY,0,0).getDay()))/604800000
}
</script>

日历时间
<style type="text/css">
body {
background-color: #D4D0C8;
}
.m_fieldset {
padding: 0,10,5,10;
text-align: center;
width: 150px;
}
.m_legend {
font-family: Tahoma;
font-size: 11px;
padding-bottom: 5px;
}
.m_frameborder {
border-left: 2px inset #D4D0C8;
border-top: 2px inset #D4D0C8;
border-right: 2px inset #FFFFFF;
border-bottom: 2px inset #FFFFFF;
width: 100px;
height: 19px;
background-color: #FFFFFF;
overflow: hidden;
text-align: right;
font-family: "Tahoma";
font-size: 10px;
}
.m_arrow {
width: 16px;
height: 8px;
font-family: "Webdings";
font-size: 7px;
line-height: 2px;
padding-left: 2px;
cursor: default;
}
.m_input {
width: 18px;
height: 14px;
border: 0px solid black;
font-family: "Tahoma";
font-size: 9px;
text-align: right;
ime-mode:disabled;
}
</style>

<script language="javascript">
// Written by cloudchen, 2004/03/15
function minute(name,fName)
{
this.name = name;
this.fName = fName || "m_input";
this.timer = null;
this.fObj = null;

this.toString = function()
{
var objDate = new Date();
var sMinute_Common = "class=\"m_input\" maxlength=\"2\" name=\""+this.fName+"\" onfocus=\""+this.name+".setFocusObj(this)\" onblur=\""+this.name+".setTime(this)\" onkeyup=\""+this.name+".prevent(this)\" onkeypress=\"if (!/[0-9]/.test(String.fromCharCode(event.keyCode)))event.keyCode=0\" onpaste=\"return false\" ondragenter=\"return false\"";
var sButton_Common = "class=\"m_arrow\" onfocus=\"this.blur()\" onmouseup=\""+this.name+".controlTime()\" disabled"
var str = "";
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
str += "<tr>"
str += "<td>"
str += "<div class=\"m_frameborder\">"
str += "<input radix=\"24\" value=\""+this.formatTime(objDate.getHours())+"\" "+sMinute_Common+">:"
str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getMinutes())+"\" "+sMinute_Common+">:"
str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getSeconds())+"\" "+sMinute_Common+">"
str += "</div>"
str += "</td>"
str += "<td>"
str += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">"
str += "<tr><td><button id=\""+this.fName+"_up\" "+sButton_Common+">5</button></td></tr>"
str += "<tr><td><button id=\""+this.fName+"_down\" "+sButton_Common+">6</button></td></tr>"
str += "</table>"
str += "</td>"
str += "</tr>"
str += "</table>"
return str;
}
this.play = function()
{
this.timer = setInterval(this.name+".playback()",1000);
}
this.formatTime = function(sTime)
{
sTime = ("0"+sTime);
return sTime.substr(sTime.length-2);
}
this.playback = function()
{
var objDate = new Date();
var arrDate = [objDate.getHours(),objDate.getMinutes(),objDate.getSeconds()];
var objMinute = document.getElementsByName(this.fName);
for (var I=0;I<objMinute.length;I++)
{
objMinute[I].value = this.formatTime(arrDate[I])
}
}
this.prevent = function(obj)
{
clearInterval(this.timer);
this.setFocusObj(obj);
var value = parseInt(obj.value,10);
var radix = parseInt(obj.radix,10)-1;
if (obj.value>radix||obj.value<0)
{
obj.value = obj.value.substr(0,1);
}
}
this.controlTime = function(cmd)
{
event.cancelBubble = true;
if (!this.fObj) return;
clearInterval(this.timer);
var cmd = event.srcElement.innerText=="5"?true:false;
var I = parseInt(this.fObj.value,10);
var radix = parseInt(this.fObj.radix,10)-1;
if (I==radix&&cmd)
{
I = 0;
}
else if (I==0&&!cmd)
{
I = radix;
}
else
{
cmd?I++:I--;
}
this.fObj.value = this.formatTime(I);
this.fObj.select();
}
this.setTime = function(obj)
{
obj.value = this.formatTime(obj.value);
}
this.setFocusObj = function(obj)
{
eval(this.fName+"_up").disabled = eval(this.fName+"_down").disabled = false;
this.fObj = obj;
}
this.getTime = function()
{
var arrTime = new Array(2);
for (var I=0;I<document.getElementsByName(this.fName).length;I++)
{
arrTime[I] = document.getElementsByName(this.fName)[I].value;
}
return arrTime.join(":");
}
}
</script>

<style type="text/css">
body {
background-color: #D4D0C8;
}
.c_fieldset {
padding: 0,10,5,10;
text-align: center;
width: 180px;
}
.c_legend {
font-family: Tahoma;
font-size: 11px;
padding-bottom: 5px;
}
.c_frameborder {
border-left: 2px inset #D4D0C8;
border-top: 2px inset #D4D0C8;
border-right: 2px inset #FFFFFF;
border-bottom: 2px inset #FFFFFF;
background-color: #FFFFFF;
overflow: hidden;
font-family: "Tahoma";
font-size: 10px;
width:160px;
height:120px;
}
.c_frameborder td {
width: 23px;
height: 16px;
font-family: "Tahoma";
font-size: 11px;
text-align: center;
cursor: default;
}
.c_frameborder .selected {
background-color:#0A246A;
width:12px;
height:12px;
color:white;
}
.c_frameborder span {
width:12px;
height:12px;
}
.c_arrow {
width: 16px;
height: 8px;
font-family: "Webdings";
font-size: 7px;
line-height: 2px;
padding-left: 2px;
cursor: default;
}
.c_year {
font-family: "Tahoma";
font-size: 11px;
cursor: default;
width:55px;
height:19px;
}
.c_month {
width:75px;
height:20px;
font:11px "Tahoma";
}
.c_dateHead {
background-color:#808080;
color:#D4D0C8;
}
</style>

<script language="javascript">
// Written by cloudchen, 2004/03/16
function calendar(name,fName)
{
this.name = name;
this.fName = fName || "calendar";
this.year = new Date().getFullYear();
this.month = new Date().getMonth();
this.date = new Date().getDate();
//private
this.toString = function()
{
var str = "";
str += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" onselectstart=\"return false\">";
str += "<tr>";
str += "<td>";
str += this.drawMonth();
str += "</td>";
str += "<td align=\"right\">";
str += this.drawYear();
str += "</td>";
str += "</tr>";
str += "<tr>";
str += "<td colspan=\"2\">";
str += "<div class=\"c_frameborder\">";
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"c_dateHead\">";
str += "<tr>";
str += "<td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td>";
str += "</tr>";
str += "</table>";
str += this.drawDate();
str += "</div>";
str += "</td>";
str += "</tr>";
str += "</table>";
return str;
}
//private
this.drawYear = function()
{
var str = "";
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
str += "<tr>";
str += "<td>";
str += "<input class=\"c_year\" maxlength=\"4\" value=\""+this.year+"\" name=\""+this.fName+"\" id=\""+this.fName+"_year\" readonly>";
//DateField
str += "<input type=\"hidden\" name=\""+this.fName+"\" value=\""+this.date+"\" id=\""+this.fName+"_date\">";
str += "</td>";
str += "<td>";
str += "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";
str += "<tr>";
str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value++;"+this.name+".redrawDate()\">5</button></td>";
str += "</tr>";
str += "<tr>";
str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value--;"+this.name+".redrawDate()\">6</button></td>";
str += "</tr>";
str += "</table>";
str += "</td>";
str += "</tr>";
str += "</table>";
return str;
}
//priavate
this.drawMonth = function()
{
var aMonthName = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];
var str = "";
str += "<select class=\"c_month\" name=\""+this.fName+"\" id=\""+this.fName+"_month\" onchange=\""+this.name+".redrawDate()\">";
for (var I=0;I<aMonthName.length;I++) {
str += "<option value=\""+(I+1)+"\" "+(I==this.month?"selected":"")+">"+aMonthName[I]+"月</option>";
}
str += "</select>";
return str;
}
//private
this.drawDate = function()
{
var str = "";
var fDay = new Date(this.year,this.month,1).getDay();
var fDate = 1-fDay;
var lDay = new Date(this.year,this.month+1,0).getDay();
var lDate = new Date(this.year,this.month+1,0).getDate();
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\""+this.fName+"_dateTable"+"\">";
for (var I=1,j=fDate;I<7;I++)
{
str += "<tr>";
for (var k=0;k<7;k++)
{
str += "<td><span"+(j==this.date?" class=\"selected\"":"")+" onclick=\""+this.name+".redrawDate(this.innerText)\">"+(isDate(j++))+"</span></td>";
}
str += "</tr>";
}
str += "</table>";
return str;

function isDate(n)
{
return (n>=1&&n<=lDate)?n:"";
}
}
//public
this.redrawDate = function(d)
{
this.year = document.getElementById(this.fName+"_year").value;
this.month = document.getElementById(this.fName+"_month").value-1;
this.date = d || this.date;
document.getElementById(this.fName+"_year").value = this.year;
document.getElementById(this.fName+"_month").selectedIndex = this.month;
document.getElementById(this.fName+"_date").value = this.date;
if (this.date>new Date(this.year,this.month+1,0).getDate()) this.date = new Date(this.year,this.month+1,0).getDate();
document.getElementById(this.fName+"_dateTable").outerHTML = this.drawDate();
}
//public
this.getDate = function(delimiter)
{
if (!delimiter) delimiter = "/";
var aValue = [this.year,(this.month+1),this.date];
return aValue.join(delimiter);
}
}
</script>
<table border="0">
<tr><td>
<fieldset class="c_fieldset"><legend class="c_legend">日期(T)</legend>
<!-- 调用日历 -->
<script>
var c = new calendar("c");
document.write?;
</script>
<!-- 调用日历 -->
</fieldset>
</td>
<td valign="top">
<fieldset class="m_fieldset"><legend class="m_legend">时间(T)</legend>
<!-- 调用时间钟 -->
<script>
var m = new minute("m");
m.play();
document.write(m);
</script>
<!-- 调用时间钟 -->
</fieldset>
</td></tr>
<tr>
<td colspan="2">
<button onclick="alert(c.getDate())" style="font:8px Webdings;width:15px;height:15px;line-height:6px;">4</button>
<button style="font:10px Arial;height:15px;height:16px;border:0px;" onfocus="this.blur()">GetDate</button>

<button onclick="alert(m.getTime())" style="font:8px Webdings;width:15px;height:15px;line-height:6px;">4</button>
<button style="font:10px Arial;height:15px;height:16px;border:0px;" onfocus="this.blur()">GetTime</button>
</td>
</tr>
</table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html xmlns:v>
<head>

<style>
<!--
v\:* {
behavior: url(#default#VML);
}
-->
</style>

<script type="text/javascript">
<!--

function updatePointers() {
var now = new Date();

secondsPointer.style.rotation = now.getSeconds() * 6;
minutesPointer.style.rotation = now.getMinutes() * 6 + now.getSeconds() / 10;
hoursPointer.style.rotation = now.getHours() * 30 + now.getMinutes() / 2;
}

window.attachEvent("onload", initVMLClock);

function initVMLClock() {
updatePointers();
window.setInterval("updatePointers()", 1000);
}

function toggle(sId) {
var el = document.getElementById(sId);

el.style.display = (el.style.display == "none") ? "block" : "none";
}

//-->
</script>

</head>
<body>

<p style="text-align: center;>
<div style="text-align: left;">
<v:group id="clock" coordsize="100 100" style="width: 200px; height: 200px; position: relative; filter: alpha(opacity=90);">
<v:oval style="width: 100%; height: 100%">
<v:stroke weight="12px" color="#eeeeee"/>
<!-- I removed this gradient fill to match the WebFX color theme
<v:fill type="gradient" color="white" color2="#eeeeff" angle="225deg"/>
-->
</v:oval>

<v:group id="secondsPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,5">
<v:stroke weight="2px" endcap="round" color="navy"/>
</v:line>
</v:group>

<v:group id="minutesPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,8">
<v:stroke weight="4px" endcap="round" color="navy"/>
</v:line>
</v:group>

<v:group id="hoursPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,18">
<v:stroke weight="8px" endcap="round" color="navy"/>
</v:line>
</v:group>

</v:group>
</div></p>

</body>
</html>

日期特效收集

关于星期几
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body bgcolor="#FFFFFF" text="#000000">
<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 = "星期六"

date = "<font class f7 color='#000000'> " + (today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " + day + "</font>";

document.write(date.fontsize(2)+"");

-->

</script>
</body>
</html>
<script>
quote=new Array(7)
quote[0]="天"
quote[1]="一"
quote[2]="二"
quote[3]="三"
quote[4]="四"
quote[5]="五"
quote[6]="六"
var Day_of_Week=new Date()
Quote_of_Day=Day_of_Week.getDay()
document.write("今天是星期" + quote[Quote_of_Day] + ",活活")
</script>

<script>
alert("今天是星期"+new Array("天","一","二","三","四","五","六").toString().split(",")[new Date().getDay()])
</script>

<script>
alert("今天是星期"+["天","一","二","三","四","五","六"][new Date().getDay()])
</script>

<script>
Date.prototype.getChineseDay = function ()
{
return "天一二三四五六".charAt(this.getDay())
}

alert("星期" + new Date().getChineseDay())
</script>

<script>
alert("今天是星期"+"天一二三四五六".charAt(new Date().getDay()))
</script>

<script language=vbs>
alert(WeekdayName(Weekday(NOW)))
</script>

关于第几周

<script>
var nowdate=new Date();
var nowyear=nowdate.getYear();
var tempdate= new Date(nowyear,0,1);
var min=nowdate.getTime();
var tempmin=tempdate.getTime();
var tempweekday=tempdate.getDay();
var week_num=((min-tempmin)/86400000+tempweekday)/7+1;
alert("第"+parseInt(week_num)+"周");
</script>

<script>
var day_list = new Array(31,28,31,30,31,30,31,31,10,31,30,31);
var days = (new Date()).getDate();
var this_month = (new Date()).getMonth();
for(I=0;I<=this_month;I++) days +=day_list[I];
alert("第"+parseInt(days/7)+"周");
</script>

<script>
function test(date)
{
var nowdate=new Date(date);
var nowyear=nowdate.getYear();
var tempdate= new Date(nowyear,0,1);
var min=nowdate.getTime();
var tempmin=tempdate.getTime();
var tempweekday=tempdate.getDay();
var week_num=((min-tempmin)/86400000+tempweekday)/7+1;
alert("第"+parseInt(week_num)+"周");
}

test("2000/12/31")
test("2002/12/31")
test("2003/1/5")
test("2003/1/6")
</script>

<script>
function test(date)
{
var nowdate=new Date(date);
var nowyear=nowdate.getYear();
var tempdate= new Date(nowyear,0,1);
var min=nowdate.getTime();
var tempmin=tempdate.getTime();
var tempweekday=tempdate.getDay();
var week_num=((min-tempmin)/86400000+tempweekday-1)/7;
alert("第"+parseInt(week_num)+"周");
}

test("2000/12/31")
test("2002/12/31")
test("2003/1/5")
test("2003/1/6")
</script>

<script>
alert(new Date(2003,0,5).getWeekly())
alert(new Date().getWeekly())

function Date.prototype.getWeekly(){
var oY=this.getFullYear()
var oM=this.getMonth()
var oD=this.getDate()
return 1+(new Date(oY,oM,oD-new Date(oY,oM,oD).getDay())-new Date(oY,0,7-new Date(oY,0,0).getDay()))/604800000
}
</script>

日历时间

<style type="text/css">
body {
background-color: #D4D0C8;
}
.m_fieldset {
padding: 0,10,5,10;
text-align: center;
width: 150px;
}
.m_legend {
font-family: Tahoma;
font-size: 11px;
padding-bottom: 5px;
}
.m_frameborder {
border-left: 2px inset #D4D0C8;
border-top: 2px inset #D4D0C8;
border-right: 2px inset #FFFFFF;
border-bottom: 2px inset #FFFFFF;
width: 100px;
height: 19px;
background-color: #FFFFFF;
overflow: hidden;
text-align: right;
font-family: "Tahoma";
font-size: 10px;
}
.m_arrow {
width: 16px;
height: 8px;
font-family: "Webdings";
font-size: 7px;
line-height: 2px;
padding-left: 2px;
cursor: default;
}
.m_input {
width: 18px;
height: 14px;
border: 0px solid black;
font-family: "Tahoma";
font-size: 9px;
text-align: right;
ime-mode:disabled;
}
</style>

<script language="javascript">
// Written by cloudchen, 2004/03/15
function minute(name,fName)
{
this.name = name;
this.fName = fName || "m_input";
this.timer = null;
this.fObj = null;

this.toString = function()
{
var objDate = new Date();
var sMinute_Common = "class=\"m_input\" maxlength=\"2\" name=\""+this.fName+"\" onfocus=\""+this.name+".setFocusObj(this)\" onblur=\""+this.name+".setTime(this)\" onkeyup=\""+this.name+".prevent(this)\" onkeypress=\"if (!/[0-9]/.test(String.fromCharCode(event.keyCode)))event.keyCode=0\" onpaste=\"return false\" ondragenter=\"return false\"";
var sButton_Common = "class=\"m_arrow\" onfocus=\"this.blur()\" onmouseup=\""+this.name+".controlTime()\" disabled"
var str = "";
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
str += "<tr>"
str += "<td>"
str += "<div class=\"m_frameborder\">"
str += "<input radix=\"24\" value=\""+this.formatTime(objDate.getHours())+"\" "+sMinute_Common+">:"
str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getMinutes())+"\" "+sMinute_Common+">:"
str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getSeconds())+"\" "+sMinute_Common+">"
str += "</div>"
str += "</td>"
str += "<td>"
str += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">"
str += "<tr><td><button id=\""+this.fName+"_up\" "+sButton_Common+">5</button></td></tr>"
str += "<tr><td><button id=\""+this.fName+"_down\" "+sButton_Common+">6</button></td></tr>"
str += "</table>"
str += "</td>"
str += "</tr>"
str += "</table>"
return str;
}
this.play = function()
{
this.timer = setInterval(this.name+".playback()",1000);
}
this.formatTime = function(sTime)
{
sTime = ("0"+sTime);
return sTime.substr(sTime.length-2);
}
this.playback = function()
{
var objDate = new Date();
var arrDate = [objDate.getHours(),objDate.getMinutes(),objDate.getSeconds()];
var objMinute = document.getElementsByName(this.fName);
for (var I=0;I<objMinute.length;I++)
{
objMinute[I].value = this.formatTime(arrDate[I])
}
}
this.prevent = function(obj)
{
clearInterval(this.timer);
this.setFocusObj(obj);
var value = parseInt(obj.value,10);
var radix = parseInt(obj.radix,10)-1;
if (obj.value>radix||obj.value<0)
{
obj.value = obj.value.substr(0,1);
}
}
this.controlTime = function(cmd)
{
event.cancelBubble = true;
if (!this.fObj) return;
clearInterval(this.timer);
var cmd = event.srcElement.innerText=="5"?true:false;
var I = parseInt(this.fObj.value,10);
var radix = parseInt(this.fObj.radix,10)-1;
if (I==radix&&cmd)
{
I = 0;
}
else if (I==0&&!cmd)
{
I = radix;
}
else
{
cmd?I++:I--;
}
this.fObj.value = this.formatTime(I);
this.fObj.select();
}
this.setTime = function(obj)
{
obj.value = this.formatTime(obj.value);
}
this.setFocusObj = function(obj)
{
eval(this.fName+"_up").disabled = eval(this.fName+"_down").disabled = false;
this.fObj = obj;
}
this.getTime = function()
{
var arrTime = new Array(2);
for (var I=0;I<document.getElementsByName(this.fName).length;I++)
{
arrTime[I] = document.getElementsByName(this.fName)[I].value;
}
return arrTime.join(":");
}
}
</script>

<style type="text/css">
body {
background-color: #D4D0C8;
}
.c_fieldset {
padding: 0,10,5,10;
text-align: center;
width: 180px;
}
.c_legend {
font-family: Tahoma;
font-size: 11px;
padding-bottom: 5px;
}
.c_frameborder {
border-left: 2px inset #D4D0C8;
border-top: 2px inset #D4D0C8;
border-right: 2px inset #FFFFFF;
border-bottom: 2px inset #FFFFFF;
background-color: #FFFFFF;
overflow: hidden;
font-family: "Tahoma";
font-size: 10px;
width:160px;
height:120px;
}
.c_frameborder td {
width: 23px;
height: 16px;
font-family: "Tahoma";
font-size: 11px;
text-align: center;
cursor: default;
}
.c_frameborder .selected {
background-color:#0A246A;
width:12px;
height:12px;
color:white;
}
.c_frameborder span {
width:12px;
height:12px;
}
.c_arrow {
width: 16px;
height: 8px;
font-family: "Webdings";
font-size: 7px;
line-height: 2px;
padding-left: 2px;
cursor: default;
}
.c_year {
font-family: "Tahoma";
font-size: 11px;
cursor: default;
width:55px;
height:19px;
}
.c_month {
width:75px;
height:20px;
font:11px "Tahoma";
}
.c_dateHead {
background-color:#808080;
color:#D4D0C8;
}
</style>

<script language="javascript">
// Written by cloudchen, 2004/03/16
function calendar(name,fName)
{
this.name = name;
this.fName = fName || "calendar";
this.year = new Date().getFullYear();
this.month = new Date().getMonth();
this.date = new Date().getDate();
//private
this.toString = function()
{
var str = "";
str += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" onselectstart=\"return false\">";
str += "<tr>";
str += "<td>";
str += this.drawMonth();
str += "</td>";
str += "<td align=\"right\">";
str += this.drawYear();
str += "</td>";
str += "</tr>";
str += "<tr>";
str += "<td colspan=\"2\">";
str += "<div class=\"c_frameborder\">";
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"c_dateHead\">";
str += "<tr>";
str += "<td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td>";
str += "</tr>";
str += "</table>";
str += this.drawDate();
str += "</div>";
str += "</td>";
str += "</tr>";
str += "</table>";
return str;
}
//private
this.drawYear = function()
{
var str = "";
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
str += "<tr>";
str += "<td>";
str += "<input class=\"c_year\" maxlength=\"4\" value=\""+this.year+"\" name=\""+this.fName+"\" id=\""+this.fName+"_year\" readonly>";
//DateField
str += "<input type=\"hidden\" name=\""+this.fName+"\" value=\""+this.date+"\" id=\""+this.fName+"_date\">";
str += "</td>";
str += "<td>";
str += "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";
str += "<tr>";
str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value++;"+this.name+".redrawDate()\">5</button></td>";
str += "</tr>";
str += "<tr>";
str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value--;"+this.name+".redrawDate()\">6</button></td>";
str += "</tr>";
str += "</table>";
str += "</td>";
str += "</tr>";
str += "</table>";
return str;
}
//priavate
this.drawMonth = function()
{
var aMonthName = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];
var str = "";
str += "<select class=\"c_month\" name=\""+this.fName+"\" id=\""+this.fName+"_month\" onchange=\""+this.name+".redrawDate()\">";
for (var I=0;I<aMonthName.length;I++) {
str += "<option value=\""+(I+1)+"\" "+(I==this.month?"selected":"")+">"+aMonthName[I]+"月</option>";
}
str += "</select>";
return str;
}
//private
this.drawDate = function()
{
var str = "";
var fDay = new Date(this.year,this.month,1).getDay();
var fDate = 1-fDay;
var lDay = new Date(this.year,this.month+1,0).getDay();
var lDate = new Date(this.year,this.month+1,0).getDate();
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\""+this.fName+"_dateTable"+"\">";
for (var I=1,j=fDate;I<7;I++)
{
str += "<tr>";
for (var k=0;k<7;k++)
{
str += "<td><span"+(j==this.date?" class=\"selected\"":"")+" onclick=\""+this.name+".redrawDate(this.innerText)\">"+(isDate(j++))+"</span></td>";
}
str += "</tr>";
}
str += "</table>";
return str;

function isDate(n)
{
return (n>=1&&n<=lDate)?n:"";
}
}
//public
this.redrawDate = function(d)
{
this.year = document.getElementById(this.fName+"_year").value;
this.month = document.getElementById(this.fName+"_month").value-1;
this.date = d || this.date;
document.getElementById(this.fName+"_year").value = this.year;
document.getElementById(this.fName+"_month").selectedIndex = this.month;
document.getElementById(this.fName+"_date").value = this.date;
if (this.date>new Date(this.year,this.month+1,0).getDate()) this.date = new Date(this.year,this.month+1,0).getDate();
document.getElementById(this.fName+"_dateTable").outerHTML = this.drawDate();
}
//public
this.getDate = function(delimiter)
{
if (!delimiter) delimiter = "/";
var aValue = [this.year,(this.month+1),this.date];
return aValue.join(delimiter);
}
}
</script>
<table border="0">
<tr><td>
<fieldset class="c_fieldset"><legend class="c_legend">日期(T)</legend>
<!-- 调用日历 -->
<script>
var c = new calendar("c");
document.write?;
</script>
<!-- 调用日历 -->
</fieldset>
</td>
<td valign="top">
<fieldset class="m_fieldset"><legend class="m_legend">时间(T)</legend>
<!-- 调用时间钟 -->
<script>
var m = new minute("m");
m.play();
document.write(m);
</script>
<!-- 调用时间钟 -->
</fieldset>
</td></tr>
<tr>
<td colspan="2">
<button onclick="alert(c.getDate())" style="font:8px Webdings;width:15px;height:15px;line-height:6px;">4</button>
<button style="font:10px Arial;height:15px;height:16px;border:0px;" onfocus="this.blur()">GetDate</button>

<button onclick="alert(m.getTime())" style="font:8px Webdings;width:15px;height:15px;line-height:6px;">4</button>
<button style="font:10px Arial;height:15px;height:16px;border:0px;" onfocus="this.blur()">GetTime</button>
</td>
</tr>
</table>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html xmlns:v>
<head>

<style>
<!--
v\:* {
behavior: url(#default#VML);
}
-->
</style>

<script type="text/javascript">
<!--

function updatePointers() {
var now = new Date();

secondsPointer.style.rotation = now.getSeconds() * 6;
minutesPointer.style.rotation = now.getMinutes() * 6 + now.getSeconds() / 10;
hoursPointer.style.rotation = now.getHours() * 30 + now.getMinutes() / 2;
}

window.attachEvent("onload", initVMLClock);

function initVMLClock() {
updatePointers();
window.setInterval("updatePointers()", 1000);
}

function toggle(sId) {
var el = document.getElementById(sId);

el.style.display = (el.style.display == "none") ? "block" : "none";
}

//-->
</script>

</head>
<body>

<p style="text-align: center;>
<div style="text-align: left;">
<v:group id="clock" coordsize="100 100" style="width: 200px; height: 200px; position: relative; filter: alpha(opacity=90);">
<v:oval style="width: 100%; height: 100%">
<v:stroke weight="12px" color="#eeeeee"/>
<!-- I removed this gradient fill to match the WebFX color theme
<v:fill type="gradient" color="white" color2="#eeeeff" angle="225deg"/>
-->
</v:oval>

<v:group id="secondsPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,5">
<v:stroke weight="2px" endcap="round" color="navy"/>
</v:line>
</v:group>

<v:group id="minutesPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,8">
<v:stroke weight="4px" endcap="round" color="navy"/>
</v:line>
</v:group>

<v:group id="hoursPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,18">
<v:stroke weight="8px" endcap="round" color="navy"/>
</v:line>
</v:group>

</v:group>
</div></p>

</body>
</html>
Share
评论Feed 评论Feed: http://www.85815.com/feed.asp?q=comment&id=152
UTF-8 Encoding 引用链接: http://www.85815.com/trackback.asp?id=152&key=
这篇日志没有评论.
发表
表情图标
[smile] [confused] [cool] [cry]
[eek] [angry] [wink] [sweat]
[lol] [stun] [razz] [redface]
[rolleyes] [sad] [yes] [no]
[heart] [star] [music] [idea]
UBB代码
转换链接
表情图标
悄悄话
用户名:   密码:   注册?
验证码 * 请输入验证码