Wed

18

Mar

2009

120、详细计算你的年龄

120、详细计算你的年龄

脚本说明:

把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

function run() {

with (document.agecalc) {

dd = parseInt(day.selectedIndex) + 1;

mm = parseInt(month.selectedIndex) + 1;

yy = year.value;

if (yy.length != 4 || isNaN(yy)) {

document.agecalc.timealive.value = "Please enter a 4-digit year.";

document.agecalc.year.select();

document.agecalc.year.focus();

return;

   }

}

days = new Date();

gdate = days.getDate();

gmonth = days.getMonth();

gyear = days.getYear();

if (gyear < 2000) gyear += 1900;

age = gyear - yy;

if ((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) {

age = age;

} else {

if (mm <= (gmonth)) {

age = age;

} else {

age = age - 1;

   }

}

if (age == 0)

age = age;

document.agecalc.timealive.value = "You are " + age+ " years old . . .\n\n";

if (mm <= (gmonth + 1))

age = age - 1;

if ((mm == (gmonth + 1)) && (dd > parseInt(gdate)))

age = age + 1;

var m;

var n;

if (mm == 12) n = 31 - dd;

if (mm == 11) n = 61 - dd;

if (mm == 10) n = 92 - dd;

if (mm == 9) n = 122 - dd;

if (mm == 8) n = 153 - dd;

if (mm == 7) n = 184 - dd;

if (mm == 6) n = 214 - dd;

if (mm == 5) n = 245 - dd;

if (mm == 4) n = 275 - dd;

if (mm == 3) n = 306 - dd;

if (mm == 2) { n = 334 - dd; if (leapyear(yy)) n++; }

if (mm == 1) { n = 365 - dd; if (leapyear(yy)) n++; }

if (gmonth == 1) m = 31;

if (gmonth == 2) {

m = 59;

if (leapyear(gyear)) m++;

}

if (gmonth == 3)  { m = 90;  if (leapyear(gyear)) m++; }

if (gmonth == 4)  { m = 120; if (leapyear(gyear)) m++; }

if (gmonth == 5)  { m = 151; if (leapyear(gyear)) m++; }

if (gmonth == 6)  { m = 181; if (leapyear(gyear)) m++; }

if (gmonth == 7)  { m = 212; if (leapyear(gyear)) m++; }

if (gmonth == 8)  { m = 243; if (leapyear(gyear)) m++; }

if (gmonth == 9)  { m = 273; if (leapyear(gyear)) m++; }

if (gmonth == 10) { m = 304; if (leapyear(gyear)) m++; }

if (gmonth == 11) { m = 334; if (leapyear(gyear)) m++; }

if (gmonth == 12) { m = 365; if (leapyear(gyear)) m++; }

months = age * 12;

months += 12 - parseInt(mm);

months += gmonth;

totdays = (parseInt(age) * 365);

totdays += age / 4;

totdays = parseInt(totdays) + gdate + m + n;

if (gmonth == 1) p = 31 + gdate;

if (gmonth == 2) {

p = 59 + gdate;

if (leapyear(gyear)) m = m+1;

}

if (gmonth == 3)  { p = 90 + gdate;  if (leapyear(gyear)) p++; }

if (gmonth == 4)  { p = 120 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 5)  { p = 151 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 6)  { p = 181 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 7)  { p = 212 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 8)  { p = 243 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 9)  { p = 273 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 10) { p = 304 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 11) { p = 334 + gdate; if (leapyear(gyear)) p++; }

if (gmonth == 12) { p = 365 + gdate; if (leapyear(gyear)) p++; }

weeks = (age * 365) + n + p;

weeks = weeks / 7;

etcdays = parseFloat(weeks) - parseInt(weeks);

etcdays = Math.round(etcdays * 7);

weeks = parseInt(weeks);

etcdays += parseInt(age / 4);

if (etcdays > 7)

weeks += parseInt(etcdays / 7);

document.agecalc.timealive.value += "     or " + weeks + " Weeks old\n";

document.agecalc.timealive.value += "     or " + months + " Months old\n";

document.agecalc.timealive.value += "     or " + totdays + " days old\n";

var time = new Date();

ghour = time.getHours();

gmin = time.getMinutes();

gsec = time.getSeconds();

hour = ((age * 365) + n + p) * 24;

hour += (parseInt(age / 4) * 24);

document.agecalc.timealive.value += "     or " + hour + " Hours old\n";

var min = (hour * 60) + gmin;

document.agecalc.timealive.value += "     or " + min + " Minutes old\n";

sec = (min * 60) + gsec;

document.agecalc.timealive.value += "     or " + sec + " Seconds old";

mm = mm - 1;

var r;

if (mm == 0) r = 0;

if (mm == 1) r = 31;

if (mm == 2) { r = 59; if (leapyear(gyear)) m++; }

if (mm == 3)  { r = 90;  if (leapyear(gyear)) r++; }

if (mm == 4)  { r = 120; if (leapyear(gyear)) r++; }

if (mm == 5)  { r = 151; if (leapyear(gyear)) r++; }

if (mm == 6)  { r = 181; if (leapyear(gyear)) r++; }

if (mm == 7)  { r = 212; if (leapyear(gyear)) r++; }

if (mm == 8)  { r = 243; if (leapyear(gyear)) r++; }

if (mm == 9)  { r = 273; if (leapyear(gyear)) r++; }

if (mm == 10) { r = 304; if (leapyear(gyear)) r++; }

if (mm == 11) { r = 334; if (leapyear(gyear)) r++; }

mm = mm + 1;

r = parseInt(r) + parseInt(dd);

 

if ((mm >= (gmonth + 1)) && (dd > gdate)) {

bday = r - m - gdate;

}

else {

if ((leapyear(gyear)) && ((mm > 2) && (dd < 29))) {

a = 366;

} else {

a = 365;

}

bday = a + (r - m - gdate);

}

nhour = 24 - parseInt(ghour);

nmin = 60 - parseInt(gmin);

nsec = 60 - parseInt(gsec);

while (bday > 366) bday -= 365;

if (((bday == 366) && (leapyear(gyear)) || ((bday == 365) && (!leapyear(gyear))))) {

document.agecalc.timealive.value += "\n\nAnd, today is your birthday!";

} else {

document.agecalc.timealive.value += "\n\nAnd, your next birthday is in:\n"

+ bday + " days " + nhour + " hrs " + nmin + " mins " + nsec + " secs";

setTimeout("run()", 1000);

   }

}

function leapyear(a) {

if (((a%4 == 0) && (a%100 != 0)) || (a%400 == 0))

return true;

else

return false;

}

//  End -->

</script>

 

<form name=agecalc>

<table>

<tr><td align=center>

Birthday:  <select name=month size=1>

<option>January

<option>February

<option>March

<option>April

<option>May

<option>June

<option>July

<option>August

<option>September

<option>October

<option>November

<option>December

</select>

 

<select name=day size=1>

<option>1

<option>2

<option>3

<option>4

<option>5

<option>6

<option>7

<option>8

<option>9

<option>10

<option>11

<option>12

<option>13

<option>14

<option>15

<option>16

<option>17

<option>18

<option>19

<option>20

<option>21

<option>22

<option>23

<option>24

<option>25

<option>26

<option>27

<option>28

<option>29

<option>30

<option>31

</select>

<input type=text name=year size=4 maxlength=4>

<br>

<input type=button name=start value="Calculate" onclick="run();"><br>

<br>

<textarea rows=12 cols=35 name=timealive>

 

0 Comments

Wed

18

Mar

2009

119、用图片显示日期

119、用图片显示日期

脚本说明:

把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JavaScript">

 

 

<!-- Begin

theDate= new Date();

months = new Array();

days = new Array();

months[1] ="image/jan.gif";

months[2] ="image/feb.gif";

months[3] ="image/mar.gif";

months[4] ="image/apr.gif";

months[5] ="image/may.gif";

months[6] ="image/jun.gif";

months[7] ="image/jul.gif";

months[8] ="image/aug.gif";

months[9] ="image/sep.gif";

months[10] ="image/oct.gif";

months[11] ="image/nov.gif";

months[12] ="image/dec.gif";

days[1] ="image/1st.gif";

days[2] ="image/2nd.gif";

days[3] ="image/3rd.gif";

days[4] ="image/4th.gif";

days[5] ="image/5th.gif";

days[6] ="image/6th.gif";

days[7] ="image/7th.gif";

days[8] ="image/8th.gif";

days[9] ="image/9th.gif";

days[10] ="image/10th.gif";

days[11] ="image/11th.gif";

days[12] ="image/12th.gif";

days[13] ="image/13th.gif";

days[14] ="image/14th.gif";

days[15] ="image/15th.gif";

days[16] ="image/16th.gif";

days[17] ="image/17th.gif";

days[18] ="image/18th.gif";

days[19] ="image/18th.gif";

days[20] ="image/20th.gif";

days[21] ="image/21st.gif";

days[22] ="image/22nd.gif";

days[23] ="image/23rd.gif";

days[24] ="image/24th.gif";

days[25] ="image/25th.gif";

days[26] ="image/26th.gif";

days[27] ="image/27th.gif";

days[28] ="image/28th.gif";

days[29] ="image/29th.gif";

days[30] ="image/30th.gif";

days[31] ="image/31st.gif";

function printDate() {

document.write('<img src="' + months[theDate.getMonth()+1] + '">'); // month

document.write('<br>');

document.write('<img src="' + days[theDate.getDate()] + '">'); // day

}

//  End -->

</script>

<script>

printDate();

</script>

 

<center>

       <TEXTAREA onmouseover=this.focus() style="BORDER-RIGHT: #000000 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #000000 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #000000 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #000000 1px solid" onfocus=this.select() name=S1 rows=7 cols=66>脚本说明:

把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JavaScript">

 

 

<!-- Begin

theDate= new Date();

months = new Array();

days = new Array();

months[1] ="jan.gif";

months[2] ="feb.gif";

months[3] ="mar.gif";

months[4] ="apr.gif";

months[5] ="may.gif";

months[6] ="jun.gif";

months[7] ="jul.gif";

months[8] ="aug.gif";

months[9] ="sep.gif";

months[10] ="oct.gif";

months[11] ="nov.gif";

months[12] ="dec.gif";

days[1] ="1st.gif";

days[2] ="2nd.gif";

days[3] ="3rd.gif";

days[4] ="4th.gif";

days[5] ="5th.gif";

days[6] ="6th.gif";

days[7] ="7th.gif";

days[8] ="8th.gif";

days[9] ="9th.gif";

days[10] ="10th.gif";

days[11] ="11th.gif";

days[12] ="12th.gif";

days[13] ="13th.gif";

days[14] ="14th.gif";

days[15] ="15th.gif";

days[16] ="16th.gif";

days[17] ="17th.gif";

days[18] ="18th.gif";

days[19] ="18th.gif";

days[20] ="20th.gif";

days[21] ="21st.gif";

days[22] ="22nd.gif";

days[23] ="23rd.gif";

days[24] ="24th.gif";

days[25] ="25th.gif";

days[26] ="26th.gif";

days[27] ="27th.gif";

days[28] ="28th.gif";

days[29] ="29th.gif";

days[30] ="30th.gif";

days[31] ="31st.gif";

function printDate() {

document.write('<img src="' + months[theDate.getMonth()+1] + '">'); // month

document.write('<br>');

document.write('<img src="' + days[theDate.getDate()] + '">'); // day

}

//  End -->

</script>

<script>

printDate();

</script>

 

 

 

0 Comments

Wed

18

Mar

2009

118、计算当月还剩天数

118、计算当月还剩天数

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

var today = new Date();

var now = today.getDate();

var year = today.getYear();

if (year < 2000) year += 1900; // Y2K fix

var month = today.getMonth();

 

var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

 

// check for leap year

if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = "29";

 

// display day left

document.write("这个月还剩 " + (monarr[month]-now) + " 天了");

//  End -->

</script>

 

0 Comments

Wed

18

Mar

2009

117、退出显示停留时间

117、退出显示停留时间

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="Javascript">

<!-- Begin

pageOpen = new Date();

function bye() {

pageClose = new Date();

minutes = (pageClose.getMinutes() - pageOpen.getMinutes());

seconds = (pageClose.getSeconds() - pageOpen.getSeconds());

time = (seconds + (minutes * 60));

if (time == 1) {

time = (time + " ");

}

else {

time = (time + " ");

   }

alert('你在本页呆了 ' + time + '.  下次可要多呆一会吧,再见!');

}

// End -->

</SCRIPT>

 

 

第二步:把<body>中的内容改为:

<body bgColor=#fef4d9  OnUnload="bye()">

 

0 Comments

Wed

18

Mar

2009

116、倒计时显示器

116、倒计时显示器

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

// Take user here after session timed out

timedouturl = "http://www.7stk.com";

 

function Minutes(data) {

for (var i = 0; i < data.length; i++)

if (data.substring(i, i + 1) == ":")

break;

return (data.substring(0, i));

}

function Seconds(data) {

for (var i = 0; i < data.length; i++)

if (data.substring(i, i + 1) == ":")

break;

return (data.substring(i + 1, data.length));

}

function Display(min, sec) {

var disp;

if (min <= 9) disp = " 0";

else disp = " ";

disp += min + ":";

if (sec <= 9) disp += "0" + sec;

else disp += sec;

return (disp);

}

function Down() {

sec--;      

if (sec == -1) { sec = 59; min--; }

document.timerform.clock.value = Display(min, sec);

window.status = "Session will time out in: " + Display(min, sec);

if (min == 0 && sec == 0) {

alert("Your session has timed out.");

window.location.href = timedouturl;

}

else down = setTimeout("Down()", 1000);

}

function timeIt() {

min = 1 * Minutes(document.timerform.clock.value);

sec = 0 + Seconds(document.timerform.clock.value);

Down();

}

//  End -->

</script>

<center>

<form name="timerform">

<input type="text" name="clock" size="7" value="2:00"><p>

</form>

</center>

 

 

第二步:把<body>区域中的内容改为

<body bgcolor="#fef4d9" OnLoad="timeIt()">

 

0 Comments

Wed

18

Mar

2009

115、计算两个日期之差

115、计算两个日期之差

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

function isValidDate(dateStr) {

// Date validation function courtesty of

// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

 

// Checks for the following valid date formats:

// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

 

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year

 

var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {

alert(dateStr + " Date is not in a valid format.")

return false;

}

month = matchArray[1]; // parse date into variables

day = matchArray[3];

year = matchArray[4];

if (month < 1 || month > 12) { // check month range

alert("Month must be between 1 and 12.");

return false;

}

if (day < 1 || day > 31) {

alert("Day must be between 1 and 31.");

return false;

}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {

alert("Month "+month+" doesn't have 31 days!")

return false;

}

if (month == 2) { // check for february 29th

var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

if (day>29 || (day==29 && !isleap)) {

alert("February " + year + " doesn't have " + day + " days!");

return false;

   }

}

return true;

}

 

function isValidTime(timeStr) {

// Time validation function courtesty of

// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

 

// Checks if time is in HH:MM:SS AM/PM format.

// The seconds and AM/PM are optional.

 

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

 

var matchArray = timeStr.match(timePat);

if (matchArray == null) {

alert("Time is not in a valid format.");

return false;

}

hour = matchArray[1];

minute = matchArray[2];

second = matchArray[4];

ampm = matchArray[6];

 

if (second=="") { second = null; }

if (ampm=="") { ampm = null }

 

if (hour < 0  || hour > 23) {

alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");

return false;

}

if (hour <= 12 && ampm == null) {

if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {

alert("You must specify AM or PM.");

return false;

   }

}

if  (hour > 12 && ampm != null) {

alert("You can't specify AM or PM for military time.");

return false;

}

if (minute < 0 || minute > 59) {

alert ("Minute must be between 0 and 59.");

return false;

}

if (second != null && (second < 0 || second > 59)) {

alert ("Second must be between 0 and 59.");

return false;

}

return true;

}

 

function dateDiff(dateform) {

date1 = new Date();

date2 = new Date();

diff  = new Date();

 

if (isValidDate(dateform.firstdate.value) && isValidTime(dateform.firsttime.value)) { // Validates first date

date1temp = new Date(dateform.firstdate.value + " " + dateform.firsttime.value);

date1.setTime(date1temp.getTime());

}

else return false; // otherwise exits

 

if (isValidDate(dateform.seconddate.value) && isValidTime(dateform.secondtime.value)) { // Validates second date

date2temp = new Date(dateform.seconddate.value + " " + dateform.secondtime.value);

date2.setTime(date2temp.getTime());

}

else return false; // otherwise exits

 

// sets difference date to difference of first date and second date

 

diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

 

timediff = diff.getTime();

 

weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));

timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

 

days = Math.floor(timediff / (1000 * 60 * 60 * 24));

timediff -= days * (1000 * 60 * 60 * 24);

 

hours = Math.floor(timediff / (1000 * 60 * 60));

timediff -= hours * (1000 * 60 * 60);

 

mins = Math.floor(timediff / (1000 * 60));

timediff -= mins * (1000 * 60);

 

secs = Math.floor(timediff / 1000);

timediff -= secs * 1000;

 

dateform.difference.value = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds";

 

return false; // form should never submit, returns false

}

//  End -->

</script>

<form onSubmit="return dateDiff(this);">

<table>

<tr><td>

<pre>

起始日期:  Date: <input type=text name=firstdate value="" size=10 maxlength=10>  (MM/DD/YYYY format)

          Time: <input type=text name=firsttime value="" size=10 maxlength=10>  (HH:MM:SSam/pm format)

 

结束日期:  Date: <input type=text name=seconddate value="" size=10 maxlength=10>  (MM/DD/YYYY format)

          Time: <input type=text name=secondtime value="" size=10 maxlength=10>  (HH:MM:SSam/pm format)

 

<center><input type=submit value="计算日期之差">

 

日期之差为:<br>

<input type=text name=difference value="" size=50>

</center>

</pre>

</td></tr>

</table>

</form>

 

0 Comments

Wed

18

Mar

2009

114、万年历

114、万年历

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

function setToday() {

var now   = new Date();

var day   = now.getDate();

var month = now.getMonth();

var year  = now.getYear();

if (year < 2000)    // Y2K Fix, Isaac Powell

year = year + 1900;

this.focusDay = day;

document.calControl.month.selectedIndex = month;

document.calControl.year.value = year;

displayCalendar(month, year);

}

function isFourDigitYear(year) {

if (year.length != 4) {

alert ("Sorry, the year must be four-digits in length.");

document.calControl.year.select();

document.calControl.year.focus();

} else { return true; }

}

function selectDate() {

var year  = document.calControl.year.value;

if (isFourDigitYear(year)) {

var day   = 0;

var month = document.calControl.month.selectedIndex;

displayCalendar(month, year);

    }

}

 

function setPreviousYear() {

var year  = document.calControl.year.value;

if (isFourDigitYear(year)) {

var day   = 0;

var month = document.calControl.month.selectedIndex;

year--;

document.calControl.year.value = year;

displayCalendar(month, year);

   }

}

function setPreviousMonth() {

var year  = document.calControl.year.value;

if (isFourDigitYear(year)) {

var day   = 0;

var month = document.calControl.month.selectedIndex;

if (month == 0) {

month = 11;

if (year > 1000) {

year--;

document.calControl.year.value = year;

}

} else { month--; }

document.calControl.month.selectedIndex = month;

displayCalendar(month, year);

   }

}

function setNextMonth() {

var year  = document.calControl.year.value;

if (isFourDigitYear(year)) {

var day   = 0;

var month = document.calControl.month.selectedIndex;

if (month == 11) {

month = 0;

year++;

document.calControl.year.value = year;

} else { month++; }

document.calControl.month.selectedIndex = month;

displayCalendar(month, year);

   }

}

function setNextYear() {

var year = document.calControl.year.value;

if (isFourDigitYear(year)) {

var day = 0;

var month = document.calControl.month.selectedIndex;

year++;

document.calControl.year.value = year;

displayCalendar(month, year);

   }

}

function displayCalendar(month, year) {      

month = parseInt(month);

year = parseInt(year);

var i = 0;

var days = getDaysInMonth(month+1,year);

var firstOfMonth = new Date (year, month, 1);

var startingPos = firstOfMonth.getDay();

days += startingPos;

document.calButtons.calPage.value  =   " Su Mo Tu We Th Fr Sa";

document.calButtons.calPage.value += "\n --------------------";

for (i = 0; i < startingPos; i++) {

if ( i%7 == 0 ) document.calButtons.calPage.value += "\n ";

document.calButtons.calPage.value += "   ";

}

for (i = startingPos; i < days; i++) {

if ( i%7 == 0 ) document.calButtons.calPage.value += "\n ";

if (i-startingPos+1 < 10)

document.calButtons.calPage.value += "0";

document.calButtons.calPage.value += i-startingPos+1;

document.calButtons.calPage.value += " ";

}

for (i=days; i<42; i++)  {

if ( i%7 == 0 ) document.calButtons.calPage.value += "\n ";

document.calButtons.calPage.value += "   ";

}

document.calControl.Go.focus();

}

function getDaysInMonth(month,year)  {

var days;

if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;

else if (month==4 || month==6 || month==9 || month==11) days=30;

else if (month==2)  {

if (isLeapYear(year)) { days=29; }

else { days=28; }

}

return (days);

}

function isLeapYear (Year) {

if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {

return (true);

} else { return (false); }

}

// End -->

</SCRIPT>

<CENTER>

<H2>万年历</H2>

<FORM NAME="calControl" onSubmit="return false;">

<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>

<TR><TD COLSPAN=7>

<CENTER>

<SELECT NAME="month" onChange="selectDate()">

<OPTION>一月

<OPTION>二月

<OPTION>三月

<OPTION>四月

<OPTION>五月

<OPTION>六月

<OPTION>七月

<OPTION>八月

<OPTION>九月

<OPTION>十月

<OPTION>十一月

<OPTION>十二月

</SELECT>

<INPUT NAME="year" TYPE=TEXT SIZE=4 MAXLENGTH=4>

<INPUT TYPE="button" NAME="Go" value="创建" onClick="selectDate()">

</CENTER>

</TD>

</TR>

</FORM>

<FORM NAME="calButtons">

<TR><TD align="center"><textarea FONT="Courier" NAME="calPage" WRAP=no ROWS=8 COLS=24>

 

0 Comments

Wed

18

Mar

2009

113、准确的计时器

113、准确的计时器

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

var ms = 0;

var state = 0;

function startstop() {

if (state == 0) {

state = 1;

then = new Date();

then.setTime(then.getTime() - ms);

} else {

state = 0;

now = new Date();

ms = now.getTime() - then.getTime();

document.stpw.time.value = ms;

   }

}

function swreset() {

state = 0;

ms = 0;

document.stpw.time.value = ms;

}

function display() {

setTimeout("display();", 50);

if (state == 1)  {now = new Date();

ms = now.getTime() - then.getTime();

document.stpw.time.value = ms;

   }

}

// End -->

</SCRIPT>

<FORM NAME="stpw">

本例的时间可以准确到百分之一秒<br>

计时:

<INPUT TYPE="text" Name="time"><br>

<INPUT TYPE="BUTTON" Name="ssbutton" VALUE="开始/停止" onClick="startstop()">

<INPUT TYPE="BUTTON" NAME="reset" VALUE="重置" onClick="swreset()">

</FORM>

 

 

 

第二步:把<body>区域中的内容为

<body bgColor=#fef4d9 onLoad="display()">

 

0 Comments

Wed

18

Mar

2009

112、绝对酷的时钟

112、绝对酷的时钟

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Original:  Kurt Grigg (kurt.grigg@virgin.net) -->

<!-- Web Site:  http://website.lineone.net/~kurt.grigg/javascript -->

<!-- Begin

fCol = '000000';  //face colour.

sCol = 'ff0000';  //seconds colour.

mCol = '000000';  //minutes colour.

hCol = '000000';  //hours colour.

H = '....';

H = H.split('');

M = '.....';

M = M.split('');

S = '......';

S = S.split('');

Ypos = 0;

Xpos = 0;

Ybase = 8;

Xbase = 8;

dots = 12;

ns = (document.layers)?1:0;

if (ns) {

dgts = '1 2 3 4 5 6 7 8 9 10 11 12';

dgts = dgts.split(' ');

for (i = 0; i < dots; i++) {

document.write('<layer name=nsDigits'+i+' top=0 left=0 height=30 width=30><center><font face=Arial,Verdana size=1 color='+fCol+'>'+dgts[i]+'</font></center></layer>');

}

for (i = 0; i < M.length; i++) {

document.write('<layer name=ny'+i+' top=0 left=0 bgcolor='+mCol+' clip="0,0,2,2"></layer>');

}

for (i = 0; i < H.length; i++) {

document.write('<layer name=nz'+i+' top=0 left=0 bgcolor='+hCol+' clip="0,0,2,2"></layer>');

}

for (i = 0; i < S.length; i++) {

document.write('<layer name=nx'+i+' top=0 left=0 bgcolor='+sCol+' clip="0,0,2,2"></layer>');

   }

}

else {

document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 1; i < dots+1; i++) {

document.write('<div id="ieDigits" style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial,Verdana;font-size:10px;color:'+fCol+';text-align:center;padding-top:10px">'+i+'</div>');

}

document.write('</div></div>')

document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < M.length; i++) {

document.write('<div id=y style="position:absolute;width:2px;height:2px;font-size:2px;background:'+mCol+'"></div>');

}

document.write('</div></div>')

document.write('</div></div>')

document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < H.length; i++) {

document.write('<div id=z style="position:absolute;width:2px;height:2px;font-size:2px;background:'+hCol+'"></div>');

}

document.write('</div></div>')

document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < S.length; i++) {

document.write('<div id=x style="position:absolute;width:2px;height:2px;font-size:2px;background:'+sCol+'"></div>');

}

document.write('</div></div>')

}

function clock() {

time = new Date ();

secs = time.getSeconds();

sec = -1.57 + Math.PI * secs/30;

mins = time.getMinutes();

min = -1.57 + Math.PI * mins/30;

hr = time.getHours();

hrs = -1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;

if (ns) {

Ypos = window.pageYOffset+window.innerHeight-60;

Xpos = window.pageXOffset+window.innerWidth-80;

}

else {

Ypos = document.body.scrollTop + window.document.body.clientHeight - 60;

Xpos = document.body.scrollLeft + window.document.body.clientWidth - 60;

}

if (ns) {

for (i = 0; i < dots; ++i){

document.layers["nsDigits"+i].top = Ypos - 5 + 40 * Math.sin(-0.49+dots+i/1.9);

document.layers["nsDigits"+i].left = Xpos - 15 + 40 * Math.cos(-0.49+dots+i/1.9);

}

for (i = 0; i < S.length; i++){

document.layers["nx"+i].top = Ypos + i * Ybase * Math.sin(sec);

document.layers["nx"+i].left = Xpos + i * Xbase * Math.cos(sec);

}

for (i = 0; i < M.length; i++){

document.layers["ny"+i].top = Ypos + i * Ybase * Math.sin(min);

document.layers["ny"+i].left = Xpos + i * Xbase * Math.cos(min);

}

for (i = 0; i < H.length; i++){

document.layers["nz"+i].top = Ypos + i * Ybase * Math.sin(hrs);

document.layers["nz"+i].left = Xpos + i * Xbase * Math.cos(hrs);

   }

}

else{

for (i=0; i < dots; ++i){

ieDigits[i].style.pixelTop = Ypos - 15 + 40 * Math.sin(-0.49+dots+i/1.9);

ieDigits[i].style.pixelLeft = Xpos - 14 + 40 * Math.cos(-0.49+dots+i/1.9);

}

for (i=0; i < S.length; i++){

x[i].style.pixelTop = Ypos + i * Ybase * Math.sin(sec);

x[i].style.pixelLeft = Xpos + i * Xbase * Math.cos(sec);

}

for (i=0; i < M.length; i++){

y[i].style.pixelTop = Ypos + i * Ybase * Math.sin(min);

y[i].style.pixelLeft = Xpos + i * Xbase * Math.cos(min);

}

for (i=0; i < H.length; i++){

z[i].style.pixelTop = Ypos + i * Ybase*Math.sin(hrs);

z[i].style.pixelLeft = Xpos + i * Xbase*Math.cos(hrs);

   }

}

setTimeout('clock()', 50);

}

if (document.layers || document.all) window.onload = clock;

//  End -->

</script>

 

0 Comments

Wed

18

Mar

2009

111、时间按钮提示

111、时间按钮提示

脚本说明:

把如下代码加入<body>区域中:

<script LANGUAGE="JavaScript">

<!-- Begin

day = new Date();

miVisit = day.getTime();

function clock() {

today = new Date();

hrNow = today.getHours();

mnNow = today.getMinutes();

scNow = today.getSeconds();

miNow = today.getTime();

if (hrNow == 0) {

hour = 12;

ap = " AM";

} else if(hrNow <= 11) {

ap = " AM";

hour = hrNow;

} else if(hrNow == 12) {

ap = " PM";

hour = 12;

} else if (hrNow >= 13) {

hour = (hrNow - 12);

ap = " PM";

}

if (hrNow >= 13) {

hour = hrNow - 12;

}

if (mnNow <= 9) {

min = "0" + mnNow;

}

else (min = mnNow)

if (scNow <= 9) {

secs = "0" + scNow;

} else {

secs = scNow;

}

time = hour + ":" + min + ":" + secs + ap;

document.form.button.value = time;

self.status = time;

setTimeout('clock()', 1000);

}

function timeInfo() {

milliSince = miNow;

milliNow = miNow - miVisit;

secsVisit = Math.round(milliNow / 1000);

minsVisit = Math.round((milliNow / 1000) / 60);

alert("欢迎光临网页特效制作网站\n\n本站域名:www.7stk.com\n\n" //\n\n表示另起一行

+ "你已经在本页面上停留了大约" + minsVisit + " "

+ secsVisit + ""+ " ");

}

document.write("<center><form name=\"form\">"

+ "<input type=button value=\"Click for info!\""

+ " name=button onClick=\"timeInfo()\"></form></center>");

onError = null;

clock();

// End -->

</script>

 

0 Comments

Wed

18

Mar

2009

110、新款万年历

110、新款万年历

脚本说明:

把如下代码加入<body>区域中:

  <script language="JavaScript">

<!-- for sucky browsers

 

Months = new Array(12);

Months[0] = "一月";

Months[1] = "二月";

Months[2] = "三月";

Months[3] = "四月";

Months[4] = "五月";

Months[5] = "六月";

Months[6] = "七月";

Months[7] = "八月";

Months[8] = "九月";

Months[9] = "十月";

Months[10] = "十一月";

Months[11] = "十二月";

 

function PadSpaces(TheString)

{

       var Spaces = "             ";

       len = Math.round((9 - TheString.length)/2);

 

       return Spaces.substring(0,len) + TheString;

}

 

function NumLeapYears(StartYear, EndYear)

{

      var LeapYears, i;

 

      if (EndYear >= StartYear){

             for(LeapYears = 0; StartYear <= EndYear; StartYear++)

             if (IsLeapYear(StartYear)) LeapYears++;

       }else{

       for(LeapYears = 0; EndYear <= StartYear; EndYear++)

             if (IsLeapYear(EndYear)) LeapYears++;

       }

      return LeapYears;

}

 

function IsLeapYear(Year)

{

       if(Math.round(Year/4) == Year/4){

              if(Math.round(Year/100) == Year/100){

                     if(Math.round(Year/400) == Year/400)

                            return true;

                     else return false;

              }else return true;

       }

       return false;

}

 

function Trim(TheString)

{

       var len;

 

       len = TheString.length;

      while(TheString.substring(0,1) == " "){ //trim left

             TheString = TheString.substring(1, len);

             len = TheString.length;

       }

 

      while(TheString.substring(len-1, len) == " "){ //trim right

             TheString = TheString.substring(0, len-1);

             len = TheString.length;

      }

      return TheString;

}

 

function DetermineMonthIdx()

{

       var i, month, month_s, len;

 

 

       month = Trim(document.calform.elements[4].value);

       len = month.length;

 

       for( i = 0; i <12; i++){

                  month_s = Months[i].substring(0,len);

              if (month_s.toUpperCase() == month.toUpperCase())

                      return (i);

      }

      return -1;

}

 

function FindNewYearStartingDay(Year)

{

      var LeapYears, Years, Day;

 

      LeapYears = NumLeapYears(1995, Year);

 

      if  (Year >=1995)

             Years = (Year -1995)+LeapYears;

      else  Years = (Year -1995)-LeapYears;

 

      if  (Year >=1995)

              Day = Math.round(((Years/7 - Math.floor(Years/7))*7)+.1);

      else  Day = Math.round(((Years/7 -  Math.ceil(Years/7))*7)-.1);

      

       if (Year >=1995){

             if(IsLeapYear(Year)) Day--;

      }else Day += 7;

 

      if(Day < 0) Day = 6;

      if(Day > 6) Day = 0;

      return Day;

}

 

function FindNumDaysInMonth(Year, Month)

{

      if(Month == 1){

            if(IsLeapYear(Year)) return 29;

            else return 28;

      }else{    

            if(Month >6) Month++;

            if(Month/2 == Math.round(Month/2))  return 31;

      }

 return 30;           

}

 

function FindMonthStartDay(NewYearDay, Year, Month)

{

      var MonthStartDay;

 

      AddArray = new Array(12);

 

      AddArray[0]=0;AddArray[1]=3;AddArray[2]=3;AddArray[3]=6;

       AddArray[4]=1;AddArray[5]=4;AddArray[6]=6;AddArray[7]=2;

       AddArray[8]=5;AddArray[9]=0;AddArray[10]=3;AddArray[11]=5;

 

      MonthStartDay = NewYearDay + AddArray[Month];

      if(IsLeapYear(Year)  && (Month ) > 1) MonthStartDay ++;

 

      if (MonthStartDay > 6) MonthStartDay -= 7;

 

      return MonthStartDay;

}

 

function  FillCalendar()

{

      var Year, Month, Midx, NewYearDay, MonthStartDay;

       var NumDaysInMonth, i, t;

 

      Year = parseFloat(document.calform.elements[1].value);

      Month = document.calform.elements[4].value;

 

      Midx  =  DetermineMonthIdx();

      if (Midx == -1){

            alert ("Can't recognize that month");

            return;

      }

 

      NewYearDay = FindNewYearStartingDay(Year);

      MonthStartDay = FindMonthStartDay(NewYearDay, Year,  Midx);

      NumDaysInMonth = FindNumDaysInMonth(Year, Midx); 

 

      for(i = 6;  i < 43;  i++){

              t = i-5-MonthStartDay;

              if ( t >= 1  &&  t <= NumDaysInMonth)

                     document.calform.elements[i].value =t;

              else document.calform.elements[i].value = "";

      }

}

 

function IncDecYear(val)

{

       var valNum = parseInt(val);

       var valNum2 = parseInt(document.calform.elements[1].value)

       document.calform.elements[1].value = valNum2 + valNum;

 

       FillCalendar()

}

 

function IncDecMonth(val)

{

       var valNum = parseInt(val);

      var Midx  =  DetermineMonthIdx();

      

       Midx += valNum;

       if(Midx > 11) Midx = 0;

       if(Midx < 0)  Midx = 11;

 

      

       document.calform.elements[4].value = PadSpaces(Months[Midx]);

 

       FillCalendar()

}

 

// -->

</script>

     <table border=1 bgcolor="#000000" cellpadding=1 cellspacing=1>

      <table border=0  cellpadding=0 cellspacing=0>

        <form name="calform">

          <tr>

            <td align=center cellpadding=0 cellspacing=0 bgcolor="#000000">

              <input

type=button value="<<" onClick="IncDecYear(-1)" name="button">

            </td>

            <th cellpadding=0 cellspacing=0 bgcolor="#aaaaaa" colspan=5

align=center>

              <input size=4 type=text value="1993" name="text">

            </th>

            <td align=center cellpadding=0 cellspacing=0 bgcolor="#000000">

              <input

type=button value=">>" onClick="IncDecYear(1)" name="button2">

            </td>

          </tr>

          <tr>

            <td align=center bgcolor="#000000">

              <input type=button value="<<"

onClick="IncDecMonth(-1)" name="button2">

            </td>

            <th bgcolor="#aaaaaa" colspan=5 align=center>

              <input size=9 type=text

value=" January " name="text">

            </th>

            <td align=center bgcolor="#000000">

              <input type=button value=">>"

onClick="IncDecMonth(1)" name="button2">

            </td>

          </tr>

          <tr>

            <th  bgcolor="#ffcccc">S</th>

            <th  bgcolor="#ccccff">M</th>

            <th  bgcolor="#ccccff">T</th>

            <th  bgcolor="#ccccff">W</th>

            <th  bgcolor="#ccccff">T</th>

            <th  bgcolor="#ccccff">F</th>

            <th  bgcolor="#ccccff">S</th>

          </tr>

          <tr>

            <td  bgcolor="#ffcccc">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

          </tr>

          <tr>

            <td  bgcolor="#ffcccc">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

          </tr>

          <tr>

            <td  bgcolor="#ffcccc">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

          </tr>

          <tr>

            <td  bgcolor="#ffcccc">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

          </tr>

          <tr>

            <td  bgcolor="#ffcccc">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff" >

              <input type=text size=2 name="text">

            </td>

          </tr>

          <tr>

            <td  bgcolor="#ffcccc">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#ccccff">

              <input type=text size=2 name="text">

            </td>

            <td  bgcolor="#3344aa" colspan=5>

              <input type=text name="text">

            </td>

          </tr>

        </form>

      </table>

    </table>

 

  <script language="JavaScript">

<!--

       myDate = new Date();

       var Month = parseInt(myDate.getMonth());

      

       document.calform.elements[1].value =  myDate.getYear();

       document.calform.elements[4].value = PadSpaces(Months[Month]);

 

       document.calform.elements[43].value = "今天是:" +

              Months[Month].substring(0,3) + " " +

              myDate.getDate() + ", " + myDate.getYear();

 

       FillCalendar();

 

// -->

</script>

 

0 Comments

Wed

18

Mar

2009

109、离开某日倒计时

109、离开某日倒计时

脚本说明:

把如下代码加入<body>区域中:

<form name="form1">

<div align="center" align="middle">

<center>2010年还有:<br>

<input type="textarea" name="left" size="35" style="text-align: center">

</center>

</div>

</form>

<script LANGUAGE="JavaScript">

startclock()

var timerID = null;

var timerRunning = false;

function showtime() {

Today = new Date();

var NowHour = Today.getHours();

var NowMinute = Today.getMinutes();

var NowMonth = Today.getMonth();

var NowDate = Today.getDate();

var NowYear = Today.getYear();

var NowSecond = Today.getSeconds();

if (NowYear <2000)

       NowYear=1900+NowYear;

Today = null;

Hourleft = 23 - NowHour

Minuteleft = 59 - NowMinute

Secondleft = 59 - NowSecond

Yearleft = 2009 - NowYear

Monthleft = 12 - NowMonth - 1

Dateleft = 31 - NowDate

if (Secondleft<0)

{

       Secondleft=60+Secondleft;

       Minuteleft=Minuteleft-1;

}

if (Minuteleft<0)

{    

       Minuteleft=60+Minuteleft;

       Hourleft=Hourleft-1;

}

if (Hourleft<0)

{

       Hourleft=24+Hourleft;

       Dateleft=Dateleft-1;

}

if (Dateleft<0)

{

       Dateleft=31+Dateleft;

       Monthleft=Monthleft-1;

}

if (Monthleft<0)

{

       Monthleft=12+Monthleft;

       Yearleft=Yearleft-1;

}

Temp=Yearleft+', '+Monthleft+', '+Dateleft+', '+Hourleft+'小时, '+Minuteleft+', '+Secondleft+''

document.form1.left.value=Temp;

timerID = setTimeout("showtime()",1000);

timerRunning = true;

}

var timerID = null;

var timerRunning = false;

function stopclock () {

if(timerRunning)

clearTimeout(timerID);

timerRunning = false;

}

function startclock () {

stopclock();

showtime();

}

// -->

</script>

 

0 Comments

Wed

18

Mar

2009

108、特酷的手表

108、特酷的手表

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT language=JavaScript>

<!-- Beginning of JavaScript -

 

var now

 

var second

var minute

var hour

 

var degreeSecond

var degreeMinute

var degreeHour

 

var timer

var stepDegree=6

var stepDegreeHour=30

 

function checkTime() {

       if (document.all) {

              now=new Date()

              second=now.getSeconds()

              minute=now.getMinutes()

              hour=now.getHours()

              if (hour>=12) {hour=hour-12}

              spinIt()

              timer=setTimeout("checkTime()",200)

       }

}

 

function spinIt() {

       window.status=hour

       secondObj.SetIdentity()

       minuteObj.SetIdentity()

       hourObj.SetIdentity()

      

       degreeSecond=180+stepDegree*second

       degreeMinute=180+stepDegree*minute

       degreeHour=180+stepDegreeHour*hour+(Math.floor(stepDegree*minute/12))

      

       secondObj.Rotate(0,0,degreeSecond)

       minuteObj.Rotate(0,0,degreeMinute)

       hourObj.Rotate(0,0,degreeHour)

}

 

// - End of JavaScript - -->

</SCRIPT>

<DIV style="LEFT: 340px; POSITION: absolute; TOP: 100px">

<DIV style="LEFT: 0px; POSITION: absolute; TOP: 0px"><IMG height=102

src="bgclock.gif" width=100> </DIV>

<DIV

style="COLOR: #444444; FONT-SIZE: 8pt; LEFT: 200px; LETTER-SPACING: 0.6em; LINE-HEIGHT: 200%; POSITION: absolute; TEXT-ALIGN: center; TOP: 20px; WIDTH: 200px; fomnt-family: Verdana"></DIV>

 

 

 

第二步:把<body>中的内容改为:

<BODY bgcolor="#fef4d9" onload=checkTime()>

 

0 Comments

Wed

18

Mar

2009

107、固定的页面时钟

107、固定的页面时钟

脚本说明:

第一步:把如下代码加入<body>区域中

<STYLE>.num {

       COLOR: white; WIDTH: 30px

}

</STYLE>

<SCRIPT language=JavaScript>

<!--

pX = 100;

pY = 100;

obs = new Array(13);

function ob() {

for (i = 0; i < 13; i++) {

if (document.all) obs[i] = new Array (eval('ob'+i).style,-100,-100);

else obs[i] = new Array (eval('document.ob'+i),-100,-100);

   }

}

function cl(a, b, c) {

if (document.all) {

if (a != 0) b += -1;

eval('c'+a+'.style.pixelTop='+(pY+(c)));

eval('c'+a+'.style.pixelLeft='+(pX+(b)));

}

else {

if (a != 0) b += 10;

eval('document.c'+a+'.top='+(pY+(c)));

eval('document.c'+a+'.left='+(pX+(b)));

   }

}

function runClock() {

for (i = 0; i < 13; i++) {

obs[i][0].left=obs[i][1]+pX;

obs[i][0].top=obs[i][2]+pY;

   }

}

var lastsec;

function timer() {

time = new Date ();

sec = time.getSeconds();

if (sec != lastsec) {

lastsec = sec;

sec = Math.PI * sec / 30;

min = Math.PI * time.getMinutes() / 30;

hr = Math.PI * time.getHours() / 6 + Math.PI * parseInt(time.getMinutes()) / 360;

for (i = 1; i < 6; i++) {

obs[i][1] = Math.sin(sec) * (44 - (i-1) * 11) - 16;

if (document.layers)obs[i][1] += 10;

obs[i][2] = -Math.cos(sec) * (44 - (i-1) * 11) - 27;

}

for (i = 6;i < 10; i++) {

obs[i][1] = Math.sin(min) * (40 - (i-6) * 10) - 16;

if (document.layers)obs[i][1] += 10;

obs[i][2] = -Math.cos(min) * (40 - (i-6) * 10) - 27;

}

for (i = 10; i < 13; i++) {

obs[i][1] = Math.sin(hr) * (37 - (i-10) * 11) - 16;

if (document.layers)obs[i][1] += 10;

obs[i][2] = -Math.cos(hr) * (37 - (i-10) * 11) - 27;

      }

   }

}

function setNum() {

cl (0, -67, -65);

cl (1, 10, -51);

cl (2, 28, -33);

cl (3, 35, -8);

cl (4, 28, 17);

cl (5, 10, 35);

cl (6, -15, 42);

cl (7, -40, 35);

cl (8, -58, 17);

cl (9, -65, -8);

cl (10, -58, -33);

cl (11, -40, -51);

cl (12, -16, -56);

}

function startClock() {

ob();

setNum();

setInterval('timer()', 100);

setInterval('runClock()', 100);

}

//-->

</SCRIPT>

 

<DIV id=c0 style="LEFT: 36px; POSITION: absolute; TOP: 36px; Z-INDEX: 2">

<TABLE>

  <TBODY>

  <TR>

    <TD bgColor=#000000 height=120 width=120></TD></TR></TBODY></TABLE></DIV>

<DIV class=num id=c1

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>1</B>

</DIV>

<DIV class=num id=c2

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>2</B>

</DIV>

<DIV class=num id=c3

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>3</B>

</DIV>

<DIV class=num id=c4

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>4</B>

</DIV>

<DIV class=num id=c5

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>5</B>

</DIV>

<DIV class=num id=c6

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>6</B>

</DIV>

<DIV class=num id=c7

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>7</B>

</DIV>

<DIV class=num id=c8

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>8</B>

</DIV>

<DIV class=num id=c9

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>9</B>

</DIV>

<DIV class=num id=c10

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>10</B>

</DIV>

<DIV class=num id=c11

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>11</B>

</DIV>

<DIV class=num id=c12

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>12</B>

</DIV>

<DIV class=num id=ob0

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 1"></DIV>

<DIV class=num id=ob1

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT

color=#0000ff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob2

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT

color=#0000ff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob3

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT

color=#0000ff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob4

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT

color=#0000ff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob5

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT

color=#0000ff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob6

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT

color=#00ffff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob7

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT

color=#00ffff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob8

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT

color=#00ffff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob9

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT

color=#00ffff size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob10

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><FONT

color=#ffff00 size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob11

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><FONT

color=#ffff00 size=+3><B>.</B></FONT> </DIV>

<DIV class=num id=ob12

style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><FONT

color=#ffff00 size=+3><B>.</B></FONT> </DIV>

 

 

 

 

 

第二步:把<body>中的内容改为:

<body onload=javascript:startClock();>

 

0 Comments

Wed

18

Mar

2009

106、按时间不同显示图片

106、按时间不同显示图片

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var x = 121;

var y = 1;

function Reload() {

x = x - y;

document.form1.clock.value = " " + x + " 秒内重新刷新";

timerID = setTimeout("Reload()", 1000);

}

var timerID = null;

var timerRunning = false;

function stopclock() {

if(timerRunning) clearTimeout(timerID);

timerRunning = false;

}

function showtime() {

var now = new Date();

var hours = now.getHours();

var minutes = now.getMinutes();

var timeValue = "" + ((hours >12) ? hours -12 :hours);

if (timeValue == "0") timeValue = 12;

timeValue += ((minutes < 10) ? ":0" : ":") + minutes;

timeValue += (hours >= 12) ? " P.M." : " A.M.";

document.form2.time.value = "当前时间为: " + timeValue;

timerID = setTimeout("showtime()",1000);

timerRunning = true;

}

function startclock() {

stopclock();

showtime();

}

//  End -->

</script>

<table border=2 width="180">

<tr align=center valign=center>

<td align=center valign=center width="180" height="140">

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var address ="" ;

var time = new Date();

var ab = time.getHours();

if ( ab >= 0 && ab < 12) {

address = "onmouse1.gif";

}

else {

address = "cursor4.gif";

}

document.write("<img src='" + address + "'>");

//  End -->

</script>

</td>

</tr>

<tr align=center valign=center>

<td align=center valign=center width="180">

<form name="form1">

<input type=text name="clock" size=20 value="正在下载页面...">

</form>

</td>

</tr>

<tr align=center valign=center>

<td align=center valign=center width="180">

<form name="form2">

<input type=text name="time" size=20>

</form>

</td>

</tr>

<tr align=center valign=center>

<td align=center valign=left width="180">

本例0-12点、12-24点显示的图片是不一样的

</td>

</tr>

</table>

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad="Reload();startclock()">

 

 

0 Comments

Wed

18

Mar

2009

105、日历生成器

105、日历生成器

脚本说明:

第一步:把如下代码加入<head>区域中:

  <SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var dDate = new Date();

var dCurMonth = dDate.getMonth();

var dCurDayOfMonth = dDate.getDate();

var dCurYear = dDate.getFullYear();

var objPrevElement = new Object();

 

function fToggleColor(myElement) {

var toggleColor = "#ff0000";

if (myElement.id == "calDateText") {

if (myElement.color == toggleColor) {

myElement.color = "";

} else {

myElement.color = toggleColor;

   }

} else if (myElement.id == "calCell") {

for (var i in myElement.children) {

if (myElement.children[i].id == "calDateText") {

if (myElement.children[i].color == toggleColor) {

myElement.children[i].color = "";

} else {

myElement.children[i].color = toggleColor;

            }

         }

      }

   }

}

function fSetSelectedDay(myElement){

if (myElement.id == "calCell") {

if (!isNaN(parseInt(myElement.children["calDateText"].innerText))) {

myElement.bgColor = "#c0c0c0";

objPrevElement.bgColor = "";

document.all.calSelectedDate.value = parseInt(myElement.children["calDateText"].innerText);

objPrevElement = myElement;

      }

   }

}

function fGetDaysInMonth(iMonth, iYear) {

var dPrevDate = new Date(iYear, iMonth, 0);

return dPrevDate.getDate();

}

function fBuildCal(iYear, iMonth, iDayStyle) {

var aMonth = new Array();

aMonth[0] = new Array(7);

aMonth[1] = new Array(7);

aMonth[2] = new Array(7);

aMonth[3] = new Array(7);

aMonth[4] = new Array(7);

aMonth[5] = new Array(7);

aMonth[6] = new Array(7);

var dCalDate = new Date(iYear, iMonth-1, 1);

var iDayOfFirst = dCalDate.getDay();

var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);

var iVarDate = 1;

var i, d, w;

if (iDayStyle == 2) {

aMonth[0][0] = "Sunday";

aMonth[0][1] = "Monday";

aMonth[0][2] = "Tuesday";

aMonth[0][3] = "Wednesday";

aMonth[0][4] = "Thursday";

aMonth[0][5] = "Friday";

aMonth[0][6] = "Saturday";

} else if (iDayStyle == 1) {

aMonth[0][0] = "Sun";

aMonth[0][1] = "Mon";

aMonth[0][2] = "Tue";

aMonth[0][3] = "Wed";

aMonth[0][4] = "Thu";

aMonth[0][5] = "Fri";

aMonth[0][6] = "Sat";

} else {

aMonth[0][0] = "Su";

aMonth[0][1] = "Mo";

aMonth[0][2] = "Tu";

aMonth[0][3] = "We";

aMonth[0][4] = "Th";

aMonth[0][5] = "Fr";

aMonth[0][6] = "Sa";

}

for (d = iDayOfFirst; d < 7; d++) {

aMonth[1][d] = iVarDate;

iVarDate++;

}

for (w = 2; w < 7; w++) {

for (d = 0; d < 7; d++) {

if (iVarDate <= iDaysInMonth) {

aMonth[w][d] = iVarDate;

iVarDate++;

      }

   }

}

return aMonth;

}

function fDrawCal(iYear, iMonth, iCellWidth, iCellHeight, sDateTextSize, sDateTextWeight, iDayStyle) {

var myMonth;

myMonth = fBuildCal(iYear, iMonth, iDayStyle);

document.write("<table border='1'>")

document.write("<tr>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][0] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][1] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][2] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][3] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][4] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][5] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT: bold'>" + myMonth[0][6] + "</td>");

document.write("</tr>");

for (w = 1; w < 7; w++) {

document.write("<tr>")

for (d = 0; d < 7; d++) {

document.write("<td align='left' valign='top' width='" + iCellWidth + "' height='" + iCellHeight + "' id=calCell style='CURSOR:Hand' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");

if (!isNaN(myMonth[w][d])) {

document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>" + myMonth[w][d] + "</font>");

} else {

document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>&nbsp;</font>");

}

document.write("</td>")

}

document.write("</tr>");

}

document.write("</table>")

}

function fUpdateCal(iYear, iMonth) {

myMonth = fBuildCal(iYear, iMonth);

objPrevElement.bgColor = "";

document.all.calSelectedDate.value = "";

for (w = 1; w < 7; w++) {

for (d = 0; d < 7; d++) {

if (!isNaN(myMonth[w][d])) {

calDateText[((7*w)+d)-7].innerText = myMonth[w][d];

} else {

calDateText[((7*w)+d)-7].innerText = " ";

         }

      }

   }

}

// End -->

</script>

 

第二步:把如下代码加入<body>区域中:

<script language="JavaScript" for=window event=onload>

<!-- Begin

var dCurDate = new Date();

frmCalendarSample.tbSelMonth.options[dCurDate.getMonth()].selected = true;

for (i = 0; i < frmCalendarSample.tbSelYear.length; i++)

if (frmCalendarSample.tbSelYear.options[i].value == dCurDate.getFullYear())

frmCalendarSample.tbSelYear.options[i].selected = true;

//  End -->

</script>

 

<form name="frmCalendarSample" method="post" action="">

<input type="hidden" name="calSelectedDate" value="">

 

<table border="1">

<tr>

<td>

<select name="tbSelMonth" onchange='fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)'>

<option value="1">January</option>

<option value="2">February</option>

<option value="3">March</option>

<option value="4">April</option>

<option value="5">May</option>

<option value="6">June</option>

<option value="7">July</option>

<option value="8">August</option>

<option value="9">September</option>

<option value="10">October</option>

<option value="11">November</option>

<option value="12">December</option>

</select>

 

<select name="tbSelYear" onchange='fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)'>

<option value="1998">1998</option>

<option value="1999">1999</option>

<option value="2000">2000</option>

<option value="2001">2001</option>

<option value="2002">2002</option>

<option value="2003">2003</option>

<option value="2004">2004</option>

<option value="2005">2005</option>

<option value="2006">2006</option>

<option value="2007">2007</option>

<option value="2008">2008</option>

<option value="2009">2009</option>

<option value="2010">2010</option>

<option value="2011">2011</option>

<option value="2012">2012</option>

<option value="2013">2013</option>

<option value="2014">2014</option>

<option value="2015">2015</option>

<option value="2016">2016</option>

<option value="2017">2017</option>

<option value="2018">2018</option>

<option value="2019">2019</option>

<option value="2020">2020</option>

 

</select>

</td>

</tr>

<tr>

<td>

<script language="JavaScript">

var dCurDate = new Date();

fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 30, 30, "12px", "bold", 1);

</script>

</td>

</tr>

</table>

</form>

 

0 Comments

Wed

18

Mar

2009

104、一款别致的万年历

104、一款别致的万年历

脚本说明:

第一步:把如下代码加入<body>区域中

<STYLE TYPE="text/css">

.normal{BACKGROUND: #ffffff}

.today {font-weight:bold;BACKGROUND: #6699cc}

.satday{color:green}

.sunday{color:red}

.days {font-weight:bold}

</STYLE>

<SCRIPT LANGUAGE="JavaScript">

var months = new Array("一月", "二月", "三月",

"四月", "五月", "六月", "七月", "八月", "九月",

"十月", "十一月", "十二月");

var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,

30, 31, 30, 31);

/*var days = new Array("Sunday", "Monday", "Tuesday",

"Wednesday", "Thursday", "Friday", "Saturday");*/

var days = new Array("","", "", "",

"", "", "");

function getDays(month, year) {

 

if (1 == month)

return ((0 == year % 4) && (0 != (year % 100))) ||

(0 == year % 400) ? 29 : 28;

else

return daysInMonth[month];

}

 

function getToday() {

//得到今天的年,,

this.now = new Date();

this.year = this.now.getFullYear();

this.month = this.now.getMonth();

this.day = this.now.getDate();

}

 

 

today = new getToday();

 

function newCalendar() {

 

today = new getToday();

var parseYear = parseInt(document.all.year

[document.all.year.selectedIndex].text);

var newCal = new Date(parseYear,

document.all.month.selectedIndex, 1);

var day = -1;

var startDay = newCal.getDay();

var daily = 0;

if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))

day = today.day;

var tableCal = document.all.calendar.tBodies.dayList;

var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());

for (var intWeek = 0; intWeek < tableCal.rows.length;intWeek++)

for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++)

{

var cell = tableCal.rows[intWeek].cells[intDay];

if ((intDay == startDay) && (0 == daily))

daily = 1;

if(day==daily)

//今天,调用今天的Class

cell.className = "today";

else if(intDay==6)

//周六

cell.className = "sunday";

else if (intDay==0)

//周日

cell.className ="satday";

else

//平常

cell.className="normal";

 

if ((daily > 0) && (daily <= intDaysInMonth))

{

cell.innerText = daily;

daily++;

}

else

cell.innerText = "";

}

}

 

function getDate() {

var sDate;

//这段代码处理鼠标点击的情况

if ("TD" == event.srcElement.tagName)

if ("" != event.srcElement.innerText)

{

sDate = document.all.year.value + "" + document.all.month.value + "" + event.srcElement.innerText + "";

alert(sDate);

}

}

</SCRIPT>

<input type="hidden" name="ret">

<TABLE ID="calendar" cellspacing="0" cellpadding="0" border=1>

<THEAD>

<TR>

<TD COLSPAN=7 ALIGN=CENTER>

<SELECT ID="month" ONCHANGE="newCalendar()">

<SCRIPT LANGUAGE="JavaScript">

for (var intLoop = 0; intLoop < months.length;

intLoop++)

document.write("<OPTION VALUE= " + (intLoop + 1) + " " +

(today.month == intLoop ?

"Selected" : "") + ">" +

months[intLoop]);

</SCRIPT>

</SELECT>

 

<SELECT ID="year" ONCHANGE="newCalendar()">

<SCRIPT LANGUAGE="JavaScript">

for (var intLoop = today.year-100; intLoop < (today.year + 64);

intLoop++)

document.write("<OPTION VALUE= " + intLoop + " " +

(today.year == intLoop ?

"Selected" : "") + ">" +

intLoop);

</SCRIPT>

</SELECT>

</TD>

</TR>

<TR CLASS="days">

<SCRIPT LANGUAGE="JavaScript">

 

document.write("<TD class=satday>" + days[0] + "</TD>");

for (var intLoop = 1; intLoop < days.length-1;

intLoop++)

document.write("<TD>" + days[intLoop] + "</TD>");

document.write("<TD class=sunday>" + days[intLoop] + "</TD>");

</SCRIPT>

</TR>

</THEAD>

<TBODY border=1 cellspacing="0" cellpadding="0" ID="dayList"ALIGN=CENTER ONCLICK="getDate()">

<SCRIPT LANGUAGE="JavaScript">

for (var intWeeks = 0; intWeeks < 6; intWeeks++) {

document.write("<TR style='cursor:hand'>");

for (var intDays = 0; intDays < days.length;

intDays++)

document.write("<TD></TD>");

document.write("</TR>");

}

</SCRIPT>

</TBODY>

</TABLE>

<Script Language="JavaScript1.2">

 

function Cancel() {

document.all.ret.value = "";

window.close();

}

 

</script>

 

 

 

 

 

第二步:把<body>中的内容改为:

<body ONLOAD="newCalendar()" OnUnload="window.returnValue = document.all.ret.value;">

 

0 Comments

Wed

18

Mar

2009

103、登陆情况时间显示

103、登陆情况时间显示

脚本说明:

把如下代码加入<body>区域中

第一步:把如下代码加入<body>

<SCRIPT LANGUAGE="JavaScript">

 

<!--  Begin

var onHours = " ";

var onMinutes = " ";

var onSeconds = " ";

var offHours = 0;

var offMinutes = 0;

var offSeconds = 0;

var logSeconds = 0;

var logMinutes = 0;

var logHours = 0;

var OnTimeValue = " ";

var OffTimeValue = " ";

var PageTimeValue = " ";

 

function getLogonTime() {

var now = new Date();

var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."

var Hours = now.getHours();

Hours = ((Hours > 12) ? Hours - 12 : Hours);

var Minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();

var Seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();

OnTimeValue =(" "

+ Hours

+ Minutes

+ Seconds

+ " "

+ ampm);

onHours = now.getHours();

onMinutes = now.getMinutes();

onSeconds = now.getSeconds(); 

}

function getLogoffTime() {

var now = new Date();

var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."

var Hours = now.getHours();

Hours = ((Hours > 12) ? Hours - 12 : Hours);

var Minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();

var Seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();

OffTimeValue =(" "

+ Hours

+ Minutes

+ Seconds

+ " "

+ ampm);

offHours = now.getHours();

offMinutes = now.getMinutes();

offSeconds = now.getSeconds();

timer();

}

function timer() {

if (offSeconds >= onSeconds) {

logSeconds = offSeconds - onSeconds; }

else {

offMinutes -= 1;

logSeconds = (offSeconds + 60) - onSeconds;     

}

if (offMinutes >= onMinutes) {

logMinutes = offMinutes - onMinutes; }

else {

offHours -= 1;

logMinutes = (offMinutes + 60) - onMinutes;

}

logHours = offHours - onHours;

logHours =  ((logHours < 10) ? "0" : ":") + logHours;

logMinutes = ((logMinutes < 10) ? ":0" : ":") + logMinutes;

logSeconds = ((logSeconds < 10) ? ":0" : ":") +logSeconds;

PageTimeValue =(" "

+ logHours

+ logMinutes

+ logSeconds);

displayTimes();

}

function displayTimes() {

alert("\n登陆时间    : " +OnTimeValue+"\n\n现在时间  : "+OffTimeValue+"\n\n停留时间 : " + PageTimeValue);

}

// End -->

</SCRIPT>

<FORM>

<INPUT TYPE="button" value="看登陆本页的情况" onClick="getLogoffTime()">

</FORM>

 

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad="getLogonTime()">

 

0 Comments

Wed

18

Mar

2009

102、有提醒功能的日历

102、有提醒功能的日历

脚本说明:

把如下代码加入<body>区域中:

<script LANGUAGE="JavaScript">

<!--

var caution = false

 

function setCookie(name, value, expires, path, domain, secure) {

       var curCookie = name + "=" + escape(value) +

              ((expires) ? "; expires=" + expires.toGMTString() : "") +

              ((path) ? "; path=" + path : "") +

              ((domain) ? "; domain=" + domain : "") +

              ((secure) ? "; secure" : "")

       if (!caution || (name + "=" + escape(value)).length <= 4000)

              document.cookie = curCookie

       else

              if (confirm("Cookie exceeds 4KB and will be cut!"))

                     document.cookie = curCookie

}

 

// name - name of the desired cookie

// * return string containing value of specified cookie or null if cookie does not exist

function getCookie(name) {

       var prefix = name + "="

       var cookieStartIndex = document.cookie.indexOf(prefix)

       if (cookieStartIndex == -1)

              return null

       var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)

       if (cookieEndIndex == -1)

              cookieEndIndex = document.cookie.length

       return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))

}

 

 

function deleteCookie(name, path, domain) {

       if (getCookie(name)) {

              document.cookie = name + "=" +

              ((path) ? "; path=" + path : "") +

              ((domain) ? "; domain=" + domain : "") +

              "; expires=Thu, 01-Jan-70 00:00:01 GMT"

       }

}

 

 

function fixDate(date) {

       var base = new Date(0)

       var skew = base.getTime()

       if (skew > 0)

              date.setTime(date.getTime() - skew)

}

 

function initCookie(monthName) {

      

       var text = ""

       for (var i = 1; i <= 31; ++i) {

              text += "^" + i + "^"

       }

 

       var now = new Date()

       fixDate(now)

 

       // set time to one month (31 days) in the future

       now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 31)

 

       setCookie(monthName + "Calendar", text, now)

}

 

function getSpecificReminder(num, monthName) {

       var prefix = "^" + num + "^"

       var totalCookie = getCookie(monthName + "Calendar")

       var startIndex = totalCookie.indexOf(prefix, 0)

       var startData = totalCookie.indexOf("^", startIndex + 1) + 1

       if (num == 31)

              var endData = totalCookie.length

       else

              var endData = totalCookie.indexOf("^", startData)

      

       return totalCookie.substring(startData, endData)

}

 

function setSpecificReminder(num, monthName, newValue) {

       var prefix = "^" + num + "^"

       var totalCookie = getCookie(monthName + "Calendar")

       var startIndex = totalCookie.indexOf(prefix, 0)

       var startData = totalCookie.indexOf("^", startIndex + 1) + 1

              if (num == 31)

              var endData = totalCookie.length

       else

              var endData = totalCookie.indexOf("^", startData)

       var now = new Date()

       fixDate(now)

 

       // set time to one month (31 days) in the future

       now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 31)

 

       setCookie(monthName + "Calendar", totalCookie.substring(0, startData) + newValue + totalCookie.substring(endData, totalCookie.length), now)

}

 

function getInput(num, monthName) {

       if (!getCookie(monthName + "Calendar"))

              initCookie(monthName)

       var newValue = prompt("今天要提醒的事为:", getSpecificReminder(num, monthName))

       if (newValue) // user did not cancel

              setSpecificReminder(num, monthName, newValue)

}

 

function getTime() {

       // initialize time-related variables with current time settings

       var now = new Date()

       var hour = now.getHours()

       var minute = now.getMinutes()

       now = null

       var ampm = ""

 

       // validate hour values    and set value of ampm

       if (hour >= 12) {

              hour -= 12

              ampm = "PM"

       } else

              ampm = "AM"

       hour = (hour == 0) ? 12 : hour

 

       // add zero digit to a one digit minute

       if (minute < 10)

              minute = "0" + minute // do not parse this number!

 

       // return time string

       return hour + ":" + minute + " " + ampm

}

 

function leapYear(year) {

       if (year % 4 == 0) // basic rule

              return true // is leap year

       return false // is not leap year

}

 

function getDays(month, year) {

       // create array to hold number of days in each month

       var ar = new Array(12)

       ar[0] = 31 // January

       ar[1] = (leapYear(year)) ? 29 : 28 // February

       ar[2] = 31 // March

       ar[3] = 30 // April

       ar[4] = 31 // May

       ar[5] = 30 // June

       ar[6] = 31 // July

       ar[7] = 31 // August

       ar[8] = 30 // September

       ar[9] = 31 // October

       ar[10] = 30 // November

       ar[11] = 31 // December

 

       // return number of days in the specified month (parameter)

       return ar[month]

}

 

function getMonthName(month) {

       // create array to hold name of each month

       var ar = new Array(12)

       ar[0] = "一月"

       ar[1] = "二月"

       ar[2] = "三月"

       ar[3] = "四月"

       ar[4] = "五月"

       ar[5] = "六月"

       ar[6] = "七月"

       ar[7] = "八月"

       ar[8] = "九月"

       ar[9] = "十月"

       ar[10] = "十一月"

       ar[11] = "十二月"

 

       // return name of specified month (parameter)

       return ar[month]

}

 

function setCal() {

       // standard time attributes

       var now = new Date()

       var year = now.getYear()

       var month = now.getMonth()

       var monthName = getMonthName(month)

       var date = now.getDate()

       now = null

 

       // create instance of first day of month, and extract the day on which it occurs

       var firstDayInstance = new Date(year, month, 1)

       var firstDay = firstDayInstance.getDay()

       firstDayInstance = null

 

       // number of days in current month

       var days = getDays(month, year)

 

       // call function to draw calendar

       drawCal(firstDay + 1, days, date, monthName, year)

}

 

function drawCal(firstDay, lastDate, date, monthName, year) {

       // constant table settings

       var headerHeight = 30 // height of the table's header cell

       var border = 1 // 3D height of table's border

       var cellspacing = 2 // width of table's border

       var headerColor = "midnightblue" // color of table's header

       var headerSize = "+3" // size of tables header font

       var colWidth = 50 // width of columns in table

       var dayCellHeight = 25 // height of cells containing days of the week

       var dayColor = "darkblue" // color of font representing week days

       var cellHeight = 20 // height of cells representing dates in the calendar

       var todayColor = "red" // color specifying today's date in the calendar

       var timeColor = "purple" // color of font representing current time

 

       // create basic table structure

       var text = "" // initialize accumulative variable to empty string

       text += '<CENTER>'

       text += '<TABLE BORDER=' + border + ' CELLSPACING=' + cellspacing + '>' // table settings

       text +=   '<TH COLSPAN=7 ALIGN="center" VALIGN="center" HEIGHT=' + headerHeight + '>' // create table header cell

       text +=          '<FONT COLOR="' + headerColor + '" SIZE=' + headerSize + '>' // set font for table header

       text +=                 monthName + ' ' + year

       text +=          '</FONT>' // close table header's font settings

       text +=   '</TH>' // close header cell

 

       // variables to hold constant settings

       var openCol = '<TD ALIGN="center" VALIGN="center" WIDTH=' + colWidth + ' HEIGHT=' + dayCellHeight + '>'

       openCol += '<FONT COLOR="' + dayColor + '">'

       var closeCol = '</FONT></TD>'

 

       // create array of abbreviated day names

       var weekDay = new Array(7)

       weekDay[0] = "星期日"

       weekDay[1] = "星期一"

       weekDay[2] = "星期二"

       weekDay[3] = "星期三"

       weekDay[4] = "星期四"

       weekDay[5] = "星期五"

       weekDay[6] = "星期六"

      

       // create first row of table to set column width and specify week day

       text += '<TR ALIGN="center" VALIGN="center">'

       for (var dayNum = 0; dayNum < 7; ++dayNum) {

              text += openCol + weekDay[dayNum] + closeCol

       }

       text += '</TR>'

      

       // declaration and initialization of two variables to help with tables

       var digit = 1

       var curCell = 1

      

       for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) {

              text += '<TR ALIGN="center" VALIGN="top">'

              for (var col = 1; col <= 7; ++col) {

                     if (digit > lastDate)

                            break

                     if (curCell < firstDay) {

                            text += '<TD></TD>';

                            curCell++

                     } else {

                            if (digit == date) { // current cell represent today's date

                                   text += '<TD HEIGHT=' + cellHeight + '>'

                                   text += '<FONT COLOR="' + todayColor + '">'

                                   text += '<A HREF="javascript:getInput(' + digit + ', \'' + monthName + '\')" onMouseOver="window.status = \'Store or retrieve data for ' + monthName + ' ' + digit + '\'; return true"><FONT COLOR="' + todayColor + '">' + digit + '</FONT></A>'

                                   text += '<BR>'

                                   text += '<FONT COLOR="' + timeColor + '" SIZE=2>'

                                   text += '<CENTER>' + getTime() + '</CENTER>'

                                   text += '</FONT>'

                                   text += '</TD>'

                            } else

                                   text += '<TD HEIGHT=' + cellHeight + '><A HREF="javascript:getInput(' + digit + ', \'' + monthName + '\')" onMouseOver="window.status = \'Store or retrieve data for ' + monthName + ' ' + digit + '\'; return true">' + digit + '</A></TD>'

                            digit++

                     }

              }

              text += '</TR>'

       }

      

       // close all basic table tags

       text += '</TABLE>'

       text += '</CENTER>'

 

       // print accumulative HTML string

       document.write(text)

}

 

setCal()

 

// -->

</script>

 

0 Comments

Wed

18

Mar

2009

99、进入页面时间警告

99、进入页面时间警告

脚本说明:

把如下代码加入<body>区域中

<script language="VBScript">

<!--

sub window_onLoad()

msgBox "欢迎光临 今天是: " & date

MsgBox "您到访的时间是: " & time

end sub

-->

</script>

 

0 Comments

Wed

18

Mar

2009

101、猜你的属相

101、猜你的属相

脚本说明:

把如下代码加入<body>区域中

<SCRIPT language=JavaScript>

<!--

function getpet () {

 

        var toyear = 1997;

        var birthyear = document.frm.inyear.value;

        var birthpet="Ox"

 

        x = (toyear - birthyear) % 12

        if ((x == 1) || (x == -11)) {

            birthpet="您属老鼠"      }

            else  {

             if (x == 0)             {

             birthpet="您属牛"           }

             else  {

              if ((x == 11) || (x == -1)) {

              birthpet="您属老虎"          }

              else  {

               if ((x == 10) || (x == -2)) {

               birthpet="您属兔子"         }

               else  {

                if ((x == 9) || (x == -3))  {

                birthpet="您属龙"         }

                else  {

                 if ((x == 8) || (x == -4))  { 

                 birthpet="您属蛇"      }

                 else  {

                  if ((x == 7) || (x == -5))  { 

                  birthpet="您属马"      }

                  else  {

                   if ((x == 6) || (x == -6))  { 

                   birthpet="您属羊"      }

                   else  {

                    if ((x == 5) || (x == -7))  {  

                    birthpet="您属猴"     }

                    else  {

                     if ((x == 4) || (x == -8))  {

                     birthpet="您属鸡"    }

                     else  {

                      if ((x == 3) || (x == -9))  {

                      birthpet="您属狗"        }

                      else  {

                       if ((x == 2) || (x == -10))  {

                       birthpet="您属猪"         }  

                      }

                     }

                    }

                   }

                  }

                 }

                }

               }

              }

             }

            }

        document.frm.birth.value = birthpet;

 

}

// -->

</SCRIPT>

<FORM name=frm>

出生年份:<INPUT name=inyear size=4 value=1975> <BR><INPUT onclick=getpet() type=button value=看看属什么><INPUT name=birth size=9></FORM>

 

0 Comments

Wed

18

Mar

2009

100、特酷剩余时间

100、特酷剩余时间

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

function getTime() {

now = new Date();

y2k = new Date("Jan 1 2008 14:00:00");

days = (y2k - now) / 1000 / 60 / 60 / 24;

daysRound = Math.floor(days);

hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);

hoursRound = Math.floor(hours);

minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);

minutesRound = Math.floor(minutes);

seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);

secondsRound = Math.round(seconds);

sec = (secondsRound == 1) ? " second." : " seconds.";

min = (minutesRound == 1) ? " minute" : " minutes, ";

hr = (hoursRound == 1) ? " hour" : " hours, ";

dy = (daysRound == 1)  ? " day" : " days, "

document.timeForm.input1.value = "剩余时间: " + daysRound  + dy + hoursRound + hr + minutesRound + min + secondsRound + sec;

newtime = window.setTimeout("getTime();", 1000);

}

//  End -->

</script>

距离: Jan 1, 2008 2:00:00 p.m.

<form name=timeForm>

<input type=text name=input1 size=70 border-style="none" style="border-bottom: 0px solid; border-left: 0px solid;border-right: 0px solid;border-top: 0px solid;font:12px arial, helvetica,sans-serif">

</form>

 

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad="getTime()">

 

0 Comments

Wed

18

Mar

2009

98、固定的右上角时钟

98、固定的右上角时钟

 

 

0 Comments

Wed

18

Mar

2009

97、跟随鼠标罗马时钟

97、跟随鼠标罗马时钟

脚本说明:

第一步:把如下代码加入<body bgcolor="#000000">区域中

<SCRIPT language=javascript>

 

oDivs = new Array()

iDivs = 0

ie = document.all ? true : false

function yo (s, x, y) {

       if (ie) oDivs[iDivs] = new Array (eval('yo'+s).style, iXTo, iYTo, x, y)

       else oDivs[iDivs] = new Array (eval('document.yo'+s), iXTo, iYTo, x, y)

       iDivs++

}

iXTo = 200

iYTo = 200

function setMove(e) {

       if (ie) {

              iXTo = event.x

              iYTo = event.y

       }

       else {

              iXTo = e.pageX

              iYTo = e.pageY

       }

       //document.forms[0].elements[0].value = iXTo+", "+iYTo

}

function move() {

       x = iXTo

       y = iYTo

       for (i=0; i<iDivs; i++) {

              oDivs[i][1] = oDivs[i][1] * 0.5 + x * 0.5

              oDivs[i][2] = oDivs[i][2] * 0.5 + y * 0.5

              oDivs[i][0].left = oDivs[i][1] + oDivs[i][3]

              oDivs[i][0].top =  oDivs[i][2] + oDivs[i][4]

              x = oDivs[i][1]

              y = oDivs[i][2]

       }

}

function dont () {

       event.returnValue = false

}

iLastS = -1

function plupp () {

       time = new Date ()

       iS = time.getSeconds()

       if (iS != iLastS) {

              iLastS = iS

              iS = 2 * 3.1415 * time.getSeconds() / 60

              iM = 2 * 3.1415 * time.getMinutes() / 60

              iH = 2 * 3.1415 * time.getHours() / 12 + 31.415 * parseInt (time.getMinutes() / 5) / 720

              for (i=13;i<16;i++) {

                     oDivs[i][3] = Math.sin(iS) * (45 - (i-13)*16) - 15

                     oDivs[i][4] = -Math.cos(iS) * (45 - (i-13)*16) - 3

              }

              for (i=16;i<19;i++) {

                     oDivs[i][3] = Math.sin(iM) * (37 - (i-16)*10) - 15

                     oDivs[i][4] = -Math.cos(iM) * (37 - (i-16)*10) - 3

              }

              for (i=19;i<22;i++) {

                     oDivs[i][3] = Math.sin(iH) * (27 - (i-19)*7) - 15

                     oDivs[i][4] = -Math.cos(iH) * (27 - (i-19)*7) - 3

              }

       }

}

 

</SCRIPT>

 

<STYLE>.crap {

       COLOR: white; CURSOR: default; FONT-FAMILY: verdana; FONT-SIZE: 10px; TEXT-ALIGN: center; WIDTH: 30px

}

</STYLE>

<DIV class=crap id=yo0

style="LEFT: 135px; POSITION: absolute; TOP: 135px; Z-INDEX: 2"><IMG alt=""

border=0 height=128 src="image/ring1.gif" width=128></DIV>

<DIV class=crap id=yo1

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 4">XII</DIV>

<DIV class=crap id=yo2

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 5">I</DIV>

<DIV class=crap id=yo3

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 6">II</DIV>

<DIV class=crap id=yo4

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 7">III</DIV>

<DIV class=crap id=yo5

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 8">IV</DIV>

<DIV class=crap id=yo6

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 9">V</DIV>

<DIV class=crap id=yo7

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 10">VI</DIV>

<DIV class=crap id=yo8

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 11">VII</DIV>

<DIV class=crap id=yo9

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 12">VIII</DIV>

<DIV class=crap id=yo10

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 13">IX</DIV>

<DIV class=crap id=yo11

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 14">X</DIV>

<DIV class=crap id=yo12

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 15">XI</DIV>

<DIV class=crap id=yo13

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 16"><IMG alt=""

border=0 height=5 src="image/plupp.gif" width=5></DIV>

<DIV class=crap id=yo14

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 17"><IMG alt=""

border=0 height=5 src="image/plupp.gif" width=5></DIV>

<DIV class=crap id=yo15

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 18"><IMG alt=""

border=0 height=5 src="image/plupp.gif" width=5></DIV>

<DIV class=crap id=yo16

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 19"><IMG alt=""

border=0 height=5 src="image/plupp1.gif" width=5></DIV>

<DIV class=crap id=yo17

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 20"><IMG alt=""

border=0 height=5 src="image/plupp1.gif" width=5></DIV>

<DIV class=crap id=yo18

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 21"><IMG alt=""

border=0 height=5 src="image/plupp1.gif" width=5></DIV>

<DIV class=crap id=yo19

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 22"><IMG alt=""

border=0 height=5 src="image/plupp0.gif" width=5></DIV>

<DIV class=crap id=yo20

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 23"><IMG alt=""

border=0 height=5 src="image/plupp0.gif" width=5></DIV>

<DIV class=crap id=yo21

style="LEFT: 200px; POSITION: absolute; TOP: 200px; Z-INDEX: 24"><IMG alt=""

border=0 height=5 src="image/plupp0.gif" width=5></DIV>

<DIV id=Layer1

style="HEIGHT: 4px; LEFT: 97px; POSITION: absolute; TOP: 372px; WIDTH: 179px; Z-INDEX: 3"><FONT

face=verdana size=1><BR></FONT></DIV>

<SCRIPT langage="javascript">

 

yo ("0", -65, -65)

 

yo ("1", -15, -58)

yo ("2", 10, -51)

yo ("3", 28, -33)

yo ("4", 35, -8)

yo ("5", 28, 17)

yo ("6", 10, 35)

yo ("7", -15, 42)

yo ("8", -40, 35)

yo ("9", -58, 17)

yo ("10", -65, -8)

yo ("11", -58, -33)

yo ("12", -40, -51)

 

yo ("13", -15, 0)

yo ("14", -15, 0)

yo ("15", -15, 0)

 

yo ("16", -15, 0)

yo ("17", -15, 0)

yo ("18", -15, 0)

 

yo ("19", -15, 0)

yo ("20", -15, 0)

yo ("21", -15, 0)

 

plupp()

setInterval ("plupp()", 200)

setInterval ("move()", 30)

if (!ie) {

       document.captureEvents (Event.MOUSEMOVE)

       document.onMouseMove = setMove

}

 

</SCRIPT>

 

 

 

 

 

第二步:把<body bgcolor="#000000">中的内容改为:

<body onmousemove=setMove() onselectstart=dont() bgcolor="#000000">

0 Comments

Wed

18

Mar

2009

96、标准世界时间

96、标准世界时间

脚本说明:

第一步:把如下代码加入<body>区域中:

 <SCRIPT LANGUAGE="JavaScript">

<!-- Begin

function GetTime() {

var dt = new Date();

var def = dt.getTimezoneOffset()/60;

var gmt = (dt.getHours() + def);

document.clock.local.value = (IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());

var rome =check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));

document.clock.rome.value = (IfZero(rome) + ending);

var isr =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));

document.clock.Israel.value = (IfZero(isr) + ending);

var msw =check24(((gmt + 3) > 24) ? ((gmt + 3) - 24) : (gmt + 3));

document.clock.msw.value = (IfZero(msw) + ending);

var baku =check24(((gmt + 4) > 24) ? ((gmt + 4) - 24) : (gmt + 4));

document.clock.baku.value = (IfZero(baku) + ending);

var del =check24(((gmt + 5) > 24) ? ((gmt + 5) - 24) : (gmt + 5));

document.clock.del.value = (IfZero(del) + ending);

var dh =check24(((gmt + 6) > 24) ? ((gmt + 6) - 24) : (gmt + 6));

document.clock.dh.value = (IfZero(dh) + ending);

var kok =check24(((gmt +7 ) > 24) ? ((gmt +7 ) - 24) : (gmt + 7));

document.clock.kok.value = (IfZero(kok) + ending);

var ho =check24(((gmt + 8) > 24) ? ((gmt + 8) - 24) : (gmt + 8));

document.clock.ho.value = (IfZero(ho) + ending);

var tky =check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));

document.clock.tky.value = (IfZero(tky) + ending);

var sdn =check24(((gmt + 10) > 24) ? ((gmt + 10) - 24) : (gmt + 10));

document.clock.sdn.value = (IfZero(sdn) + ending);

var mag =check24(((gmt + 11) > 24) ? ((gmt + 11) - 24) : (gmt + 11));

document.clock.mag.value = (IfZero(mag) + ending);

var wll =check24(((gmt + 12) > 24) ? ((gmt + 12) - 24) : (gmt + 12));

document.clock.wll.value = (IfZero(wll) + ending);

 

var _GMT =check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));

 

document.clock._GMT.value = (IfZero(_GMT) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var eniw =check24(((gmt + (24-12)) > 24) ? ((gmt + (24-12)) - 24) : (gmt + (24-12)));

document.clock.eniw.value = (IfZero(eniw) + ending);

var sam =check24(((gmt + (24-11)) > 24) ? ((gmt + (24-11)) - 24) : (gmt + (24-11)));

document.clock.sam.value = (IfZero(sam) + ending);

var haw =check24(((gmt + (24-10)) > 24) ? ((gmt + (24-10)) - 24) : (gmt + (24-10)));

document.clock.Hawaii.value = (IfZero(haw) + ending);

var ala =check24(((gmt + (24-9)) > 24) ? ((gmt + (24-9)) - 24) : (gmt + (24-9)));

document.clock.alaska.value = (IfZero(ala) + ending);

var pacif =check24(((gmt + (24-8)) >= 24) ? ((gmt + (24-8)) - 24) : (gmt + (24-8)));

document.clock.pacif.value = (IfZero(pacif) + ending);

var mount =check24(((gmt + (24-7)) > 24) ? ((gmt + (24-7)) - 24) : (gmt + (24-7)));

document.clock.mount.value = (IfZero(mount) + ending);

var center =check24(((gmt + (24-6)) > 24) ? ((gmt + (24-6)) - 24) : (gmt + (24-6)));

document.clock.center.value = (IfZero(center) + ending);

var east =check24(((gmt + (24-5)) > 24) ? ((gmt + (24-5)) - 24) : (gmt + (24-5)));

document.clock.east.value = (IfZero(east) + ending);

var atl =check24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));

document.clock.atl.value = (IfZero(atl) + ending);

var bra =check24(((gmt + (24-3)) > 24) ? ((gmt + (24-3)) - 24) : (gmt + (24-3)));

bra = (bra >= 24) ? bra - 24 : bra;

document.clock.bra.value = (IfZero(bra) + ending);

var mid =check24(((gmt + (24-2)) > 24) ? ((gmt + (24-2)) - 24) : (gmt + (24-2)));

mid = (mid >= 24) ? mid - 24 : mid;

document.clock.mid.value = (IfZero(mid) + ending);

var azo =check24(((gmt + (24-1)) > 24) ? ((gmt + (24-1)) - 24) : (gmt + (24-1)));

azo = (azo >= 24) ? azo - 24 : azo;

document.clock.azo.value = (IfZero(azo) + ending);

setTimeout("GetTime()", 1000);

}

function IfZero(num) {

return ((num <= 9) ? ("0" + num) : num);

}

function check24(hour) {

return (hour >= 24) ? hour - 24 : hour;

}

//  End -->

</script>

<form name="clock">

<strong>Local Time <input type="text" size="8" name="local"></strong>

<p>

Eniwetok (GMT-12)  <input type="text" size="8" name="eniw"><br>

Samoa (GMT-11)  <input type="text" size="8" name="sam"><br>

Hawaii (GMT-10)  <input type="text" size="8" name="Hawaii">

<p>

Alaska (GMT-9)  <input type="text" size="8" name="alaska"><br>

Pacific Time (GMT-8)  <input type="text" size="8" name="pacif"><br>

Mountain Time (GMT-7)  <input type="text" size="8" name="mount">

<p>

Central Time (GMT-6)  <input type="text" size="8" name="center"><br>

Eastern Time (GMT-5)  <input type="text" size="8" name="east"><br>

Atlantic Time (GMT-4)  <input type="text" size="8" name="atl">

<p>

Brazilia (GMT-3)  <input type="text" size="8" name="bra"><br>

Mid-Atlantic (GMT-2)  <input type="text" size="8" name="mid"><br>

Azores (GMT-1)  <input type="text" size="8" name="azo">

<p>

<strong>Greenwich Mean Time (GMT)  <input type="text" size="8" name="_GMT"></strong>

<p>

Rome (GMT +1)  <input type="text" size="8" name="rome"><br>

Israel (GMT +2)  <input type="text" size="8" name="Israel"><br>

Moscow (GMT +3)  <input type="text" size="8" name="msw">

<p>

Baku (GMT +4)  <input type="text" size="8" name="baku"><br>

New Delhi (GMT +5)  <input type="text" size="8" name="del"><br>

Dhakar (GMT +6)  <input type="text" size="8" name="dh">

<p>

Bangkok (GMT +7)  <input type="text" size="8" name="kok"><br>

Hong Kong (GMT +8)  <input type="text" size="8" name="ho"><br>

Tokyo (GMT +9)  <input type="text" size="8" name="tky">

<p>

Sydney (GMT +10)  <input type="text" size="8" name="sdn"><br>

Magadan (GMT +11)  <input type="text" size="8" name="mag"><br>

Wellington (GMT +12)  <input type="text" size="8" name="wll">

</form>

 

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad="javascript:GetTime();">

 

0 Comments

Wed

18

Mar

2009

95、又一万年历

95、又一万年历

脚本说明:

把如下代码加入<body>区域中

<script>

var weekend = [0,6];

var weekendColor = "#e0e0e0";

var fontface = "Verdana";

var fontsize = 2;

var gNow = new Date();

var ggWinCal;

isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;

isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

Calendar.Months = ["January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "December"];

// Non-Leap year Month days..

Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

// Leap year Month days..

Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {

       if ((p_month == null) && (p_year == null))       return;

       if (p_WinCal == null)

              this.gWinCal = ggWinCal;

       else

              this.gWinCal = p_WinCal;

      

       if (p_month == null) {

              this.gMonthName = null;

              this.gMonth = null;

              this.gYearly = true;

       } else {

              this.gMonthName = Calendar.get_month(p_month);

              this.gMonth = new Number(p_month);

              this.gYearly = false;

       }

       this.gYear = p_year;

       this.gFormat = p_format;

       this.gBGColor = "white";

       this.gFGColor = "black";

       this.gTextColor = "black";

       this.gHeaderColor = "black";

       this.gReturnItem = p_item;

}

Calendar.get_month = Calendar_get_month;

Calendar.get_daysofmonth = Calendar_get_daysofmonth;

Calendar.calc_month_year = Calendar_calc_month_year;

Calendar.print = Calendar_print;

function Calendar_get_month(monthNo) {

       return Calendar.Months[monthNo];

}

function Calendar_get_daysofmonth(monthNo, p_year) {

       /*

       Check for leap year ..

       1.Years evenly divisible by four are normally leap years, except for...

       2.Years also evenly divisible by 100 are not leap years, except for...

       3.Years also evenly divisible by 400 are leap years.

       */

       if ((p_year % 4) == 0) {

              if ((p_year % 100) == 0 && (p_year % 400) != 0)

                     return Calendar.DOMonth[monthNo];

      

              return Calendar.lDOMonth[monthNo];

       } else

              return Calendar.DOMonth[monthNo];

}

function Calendar_calc_month_year(p_Month, p_Year, incr) {

       /*

       Will return an 1-D array with 1st element being the calculated month

       and second being the calculated year

       after applying the month increment/decrement as specified by 'incr' parameter.

       'incr' will normally have 1/-1 to navigate thru the months.

       */

       var ret_arr = new Array();

      

       if (incr == -1) {

              // B A C K W A R D

              if (p_Month == 0) {

                     ret_arr[0] = 11;

                     ret_arr[1] = parseInt(p_Year) - 1;

              }

              else {

                     ret_arr[0] = parseInt(p_Month) - 1;

                     ret_arr[1] = parseInt(p_Year);

              }

       } else if (incr == 1) {

              // F O R W A R D

              if (p_Month == 11) {

                     ret_arr[0] = 0;

                     ret_arr[1] = parseInt(p_Year) + 1;

              }

              else {

                     ret_arr[0] = parseInt(p_Month) + 1;

                     ret_arr[1] = parseInt(p_Year);

              }

       }

      

       return ret_arr;

}

function Calendar_print() {

       ggWinCal.print();

}

function Calendar_calc_month_year(p_Month, p_Year, incr) {

       /*

       Will return an 1-D array with 1st element being the calculated month

       and second being the calculated year

       after applying the month increment/decrement as specified by 'incr' parameter.

       'incr' will normally have 1/-1 to navigate thru the months.

       */

       var ret_arr = new Array();

      

       if (incr == -1) {

              // B A C K W A R D

              if (p_Month == 0) {

                     ret_arr[0] = 11;

                     ret_arr[1] = parseInt(p_Year) - 1;

              }

              else {

                     ret_arr[0] = parseInt(p_Month) - 1;

                     ret_arr[1] = parseInt(p_Year);

              }

       } else if (incr == 1) {

              // F O R W A R D

              if (p_Month == 11) {

                     ret_arr[0] = 0;

                     ret_arr[1] = parseInt(p_Year) + 1;

              }

              else {

                     ret_arr[0] = parseInt(p_Month) + 1;

                     ret_arr[1] = parseInt(p_Year);

              }

       }

      

       return ret_arr;

}

// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.

new Calendar();

Calendar.prototype.getMonthlyCalendarCode = function() {

       var vCode = "";

       var vHeader_Code = "";

       var vData_Code = "";

      

       // Begin Table Drawing code here..

       vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";

      

       vHeader_Code = this.cal_header();

       vData_Code = this.cal_data();

       vCode = vCode + vHeader_Code + vData_Code;

      

       vCode = vCode + "</TABLE>";

      

       return vCode;

}

Calendar.prototype.show = function() {

       var vCode = "";

      

       this.gWinCal.document.open();

       // Setup the page...

       this.wwrite("<html>");

       this.wwrite("<head><title>Calendar</title>");

       this.wwrite("</head>");

       this.wwrite("<body " +

              "link=\"" + this.gLinkColor + "\" " +

              "vlink=\"" + this.gLinkColor + "\" " +

              "alink=\"" + this.gLinkColor + "\" " +

              "text=\"" + this.gTextColor + "\">");

       this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");

       this.wwriteA(this.gMonthName + " " + this.gYear);

       this.wwriteA("</B><BR>");

       // Show navigation buttons

       var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);

       var prevMM = prevMMYYYY[0];

       var prevYYYY = prevMMYYYY[1];

       var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);

       var nextMM = nextMMYYYY[0];

       var nextYYYY = nextMMYYYY[1];

      

       this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"" +

              "javascript:window.opener.Build(" +

              "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +

              ");" +

              "\"><<<\/A>]</TD><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"" +

              "javascript:window.opener.Build(" +

              "'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +

              ");" +

              "\"><<\/A>]</TD><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"" +

              "javascript:window.opener.Build(" +

              "'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +

              ");" +

              "\">><\/A>]</TD><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"" +

              "javascript:window.opener.Build(" +

              "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +

              ");" +

              "\">>><\/A>]</TD></TR></TABLE><BR>");

       // Get the complete calendar code for the month..

       vCode = this.getMonthlyCalendarCode();

       this.wwrite(vCode);

       this.wwrite("</font></body></html>");

       this.gWinCal.document.close();

}

Calendar.prototype.showY = function() {

       var vCode = "";

       var i;

       var vr, vc, vx, vy;          // Row, Column, X-coord, Y-coord

       var vxf = 285;               // X-Factor

       var vyf = 200;               // Y-Factor

       var vxm = 10;               // X-margin

       var vym;                      // Y-margin

       if (isIE)   vym = 75;

       else if (isNav) vym = 25;

      

       this.gWinCal.document.open();

       this.wwrite("<html>");

       this.wwrite("<head><title>Calendar</title>");

       this.wwrite("<style type='text/css'>\n<!--");

       for (i=0; i<12; i++) {

              vc = i % 3;

              if (i>=0 && i<= 2)       vr = 0;

              if (i>=3 && i<= 5)       vr = 1;

              if (i>=6 && i<= 8)       vr = 2;

              if (i>=9 && i<= 11)      vr = 3;

             

              vx = parseInt(vxf * vc) + vxm;

              vy = parseInt(vyf * vr) + vym;

              this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");

       }

       this.wwrite("-->\n</style>");

       this.wwrite("</head>");

       this.wwrite("<body " +

              "link=\"" + this.gLinkColor + "\" " +

              "vlink=\"" + this.gLinkColor + "\" " +

              "alink=\"" + this.gLinkColor + "\" " +

              "text=\"" + this.gTextColor + "\">");

       this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");

       this.wwrite("Year : " + this.gYear);

       this.wwrite("</B><BR>");

       // Show navigation buttons

       var prevYYYY = parseInt(this.gYear) - 1;

       var nextYYYY = parseInt(this.gYear) + 1;

      

       this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"" +

              "javascript:window.opener.Build(" +

              "'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +

              ");" +

              "\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");

       this.wwrite("[<A HREF=\"" +

              "javascript:window.opener.Build(" +

              "'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +

              ");" +

              "\">>><\/A>]</TD></TR></TABLE><BR>");

       // Get the complete calendar code for each month..

       var j;

       for (i=11; i>=0; i--) {

              if (isIE)

                     this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

              else if (isNav)

                     this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

              this.gMonth = i;

              this.gMonthName = Calendar.get_month(this.gMonth);

              vCode = this.getMonthlyCalendarCode();

              this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");

              this.wwrite(vCode);

              if (isIE)

                     this.wwrite("</DIV>");

              else if (isNav)

                     this.wwrite("</LAYER>");

       }

       this.wwrite("</font><BR></body></html>");

       this.gWinCal.document.close();

}

Calendar.prototype.wwrite = function(wtext) {

       this.gWinCal.document.writeln(wtext);

}

Calendar.prototype.wwriteA = function(wtext) {

       this.gWinCal.document.write(wtext);

}

Calendar.prototype.cal_header = function() {

       var vCode = "";

      

       vCode = vCode + "<TR>";

       vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";

       vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";

       vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";

       vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";

       vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";

       vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";

       vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";

       vCode = vCode + "</TR>";

      

       return vCode;

}

Calendar.prototype.cal_data = function() {

       var vDate = new Date();

       vDate.setDate(1);

       vDate.setMonth(this.gMonth);

       vDate.setFullYear(this.gYear);

       var vFirstDay=vDate.getDay();

       var vDay=1;

       var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);

       var vOnLastDay=0;

       var vCode = "";

       /*

       Get day for the 1st of the requested month/year..

       Place as many blank cells before the 1st day of the month as necessary.

       */

       vCode = vCode + "<TR>";

       for (i=0; i<vFirstDay; i++) {

              vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";

       }

       // Write rest of the 1st week

       for (j=vFirstDay; j<7; j++) {

              vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +

                     "<A HREF='#' " +

                            "onClick=\"self.opener.document." + this.gReturnItem + ".value='" +

                            this.format_data(vDay) +

                            "';window.close();\">" +

                            this.format_day(vDay) +

                     "</A>" +

                     "</FONT></TD>";

              vDay=vDay + 1;

       }

       vCode = vCode + "</TR>";

       // Write the rest of the weeks

       for (k=2; k<7; k++) {

              vCode = vCode + "<TR>";

              for (j=0; j<7; j++) {

                     vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +

                            "<A HREF='#' " +

                                   "onClick=\"self.opener.document." + this.gReturnItem + ".value='" +

                                   this.format_data(vDay) +

                                   "';window.close();\">" +

                            this.format_day(vDay) +

                            "</A>" +

                            "</FONT></TD>";

                     vDay=vDay + 1;

                     if (vDay > vLastDay) {

                            vOnLastDay = 1;

                            break;

                     }

              }

              if (j == 6)

                     vCode = vCode + "</TR>";

              if (vOnLastDay == 1)

                     break;

       }

      

       // Fill up the rest of last week with proper blanks, so that we get proper square blocks

       for (m=1; m<(7-j); m++) {

              if (this.gYearly)

                     vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +

                     "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";

              else

                     vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +

                     "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";

       }

      

       return vCode;

}

Calendar.prototype.format_day = function(vday) {

       var vNowDay = gNow.getDate();

       var vNowMonth = gNow.getMonth();

       var vNowYear = gNow.getFullYear();

       if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)

              return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");

       else

              return (vday);

}

Calendar.prototype.write_weekend_string = function(vday) {

       var i;

       // Return special formatting for the weekend day.

       for (i=0; i<weekend.length; i++) {

              if (vday == weekend[i])

                     return (" BGCOLOR=\"" + weekendColor + "\"");

       }

      

       return "";

}

Calendar.prototype.format_data = function(p_day) {

       var vData;

       var vMonth = 1 + this.gMonth;

       vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;

       var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();

       var vFMon = Calendar.get_month(this.gMonth).toUpperCase();

       var vY4 = new String(this.gYear);

       var vY2 = new String(this.gYear.substr(2,2));

       var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

       switch (this.gFormat) {

              case "MM\/DD\/YYYY" :

                     vData = vMonth + "\/" + vDD + "\/" + vY4;

                     break;

              case "MM\/DD\/YY" :

                     vData = vMonth + "\/" + vDD + "\/" + vY2;

                     break;

              case "MM-DD-YYYY" :

                     vData = vMonth + "-" + vDD + "-" + vY4;

                     break;

              case "MM-DD-YY" :

                     vData = vMonth + "-" + vDD + "-" + vY2;

                     break;

              case "DD\/MON\/YYYY" :

                     vData = vDD + "\/" + vMon + "\/" + vY4;

                     break;

              case "DD\/MON\/YY" :

                     vData = vDD + "\/" + vMon + "\/" + vY2;

                     break;

              case "DD-MON-YYYY" :

                     vData = vDD + "-" + vMon + "-" + vY4;

                     break;

              case "DD-MON-YY" :

                     vData = vDD + "-" + vMon + "-" + vY2;

                     break;

              case "DD\/MONTH\/YYYY" :

                     vData = vDD + "\/" + vFMon + "\/" + vY4;

                     break;

              case "DD\/MONTH\/YY" :

                     vData = vDD + "\/" + vFMon + "\/" + vY2;

                     break;

              case "DD-MONTH-YYYY" :

                     vData = vDD + "-" + vFMon + "-" + vY4;

                     break;

              case "DD-MONTH-YY" :

                     vData = vDD + "-" + vFMon + "-" + vY2;

                     break;

              case "DD\/MM\/YYYY" :

                     vData = vDD + "\/" + vMonth + "\/" + vY4;

                     break;

              case "DD\/MM\/YY" :

                     vData = vDD + "\/" + vMonth + "\/" + vY2;

                     break;

              case "DD-MM-YYYY" :

                     vData = vDD + "-" + vMonth + "-" + vY4;

                     break;

              case "DD-MM-YY" :

                     vData = vDD + "-" + vMonth + "-" + vY2;

                     break;

              default :

                     vData = vMonth + "\/" + vDD + "\/" + vY4;

       }

       return vData;

}

function Build(p_item, p_month, p_year, p_format) {

       var p_WinCal = ggWinCal;

       gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);

       // Customize your Calendar here..

       gCal.gBGColor="white";

       gCal.gLinkColor="black";

       gCal.gTextColor="black";

       gCal.gHeaderColor="darkgreen";

       // Choose appropriate show function

       if (gCal.gYearly)    gCal.showY();

       else  gCal.show();

}

function show_calendar() {

       /*

              p_month : 0-11 for Jan-Dec; 12 for All Months.

              p_year     : 4-digit year

              p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)

              p_item    : Return Item.

       */

       p_item = arguments[0];

       if (arguments[1] == null)

              p_month = new String(gNow.getMonth());

       else

              p_month = arguments[1];

       if (arguments[2] == "" || arguments[2] == null)

              p_year = new String(gNow.getFullYear().toString());

       else

              p_year = arguments[2];

       if (arguments[3] == null)

              p_format = "MM/DD/YYYY";

       else

              p_format = arguments[3];

       vWinCal = window.open("", "Calendar",

              "width=250,height=250,status=no,resizable=no,top=200,left=200");

       vWinCal.opener = self;

       ggWinCal = vWinCal;

       Build(p_item, p_month, p_year, p_format);

}

/*

Yearly Calendar Code Starts here

*/

function show_yearly_calendar(p_item, p_year, p_format) {

       // Load the defaults..

       if (p_year == null || p_year == "")

              p_year = new String(gNow.getFullYear().toString());

       if (p_format == null || p_format == "")

              p_format = "MM/DD/YYYY";

       var vWinCal = window.open("", "Calendar", "scrollbars=yes");

       vWinCal.opener = self;

       ggWinCal = vWinCal;

       Build(p_item, null, p_year, p_format);

}

</script>

<center>

<form name=calform>

<input type=text name="datebox" size=15><a href="javascript:show_calendar('calform.datebox');" onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;"><img src="show-calendar.gif" width=24 height=22 border=0></a>

</form>

</center>

 

0 Comments

Wed

18

Mar

2009

94、月有阴晴圆缺

94、月有阴晴圆缺

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

var black = "black0428.gif";

var white = "white0428.gif";

var height=1;

var size = 50;

var i;

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 percentRaw = (moonPhaseTime / lunarPeriod);

var percent = Math.round(100*percentRaw) / 100;

var percentBy2 = Math.round(200*percentRaw);

var left = (percentRaw >= 0.5) ? black : white;

var right = (percentRaw >= 0.5) ? white : black;

var time = Math.round((lunarPeriod-moonPhaseTime)/(24*3600*1000));

document.write("<center>");

if (percentBy2 > 100) {

percentBy2 = percentBy2 - 100;

}

for (i = -(size-1); i < size; ++i) {

var wid=2*parseFloat(Math.sqrt((size*size)-(i*i)));

if (percentBy2 != 100)

document.write ("<img src="+left +" height=1 width="+(wid*((100-percentBy2)/100))+">");

if (percentBy2 != 0)

document.write("<img src="+right+" height=1 width="+(wid*((percentBy2)/100))+">");

document.write("<br>");

}

document.write("<BR><FONT SIZE=4>下一次月圆应该在 ",time," 天之内");

if (time > 1) document.write("s");

document.write("</font>");

</script>

 

0 Comments

Wed

18

Mar

2009

93、带开关的时钟

93、带开关的时钟

脚本说明:

第一步:把如下代码加入<body>区域中

<script language="JavaScript">

var enabled = 0;

function TOfunc() {

TO = window.setTimeout( "TOfunc()", 1000 );

var today = new Date();

document.forms[0].elements[0].value = today.toString();}

</SCRIPT>

<script language="JavaScript">

function Stopfunc(){

clearTimeout(TO);

var enabled = 0;

}

</SCRIPT>

<FORM>

<input type="text" name="disp" value="" size=25 onFocus="this.blur()"><br>

<input type="radio" name="rad" value="OFF" onClick="Stopfunc();"><b>OFF</b>

<input type="radio" name="rad" value="ON" checked onClick="TOfunc();"><b>ON</b><br>

</form>

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onload="TOfunc()">

 

0 Comments

Wed

18

Mar

2009

92、用*号做成的时钟

92、用*号做成的时钟

脚本说明:

把如下代码加入<body>区域中

<script LANGUAGE="JavaScript1.2">

colors = new Array('330099','00ff00','ff00ff');

sCol = 'ff00ff';

mCol = '00ff00';

hCol = 'red';

H = '***';

H = H.split('');

H = H.reverse();

M = '****';

M = M.split('');

M = M.reverse();

S = '*****';

S = S.split('');

S = S.reverse();

dots = 12;

var Ypos = 0,Xpos = 0,Ybase = 0,Xbase = 0;

var ay = 0, ax = 0, Ay = 0, Ax = 0, by = 0, bx = 0, By = 0, Bx = 0, cy

= 0, cx = 0, Cy = 0, Cx = 0, dy = 0, dx = 0, Dy = 0, Dx = 0;

count = 0;

count_a = 0;

move = 1;

ie4=document.all

ns = (document.layers)?1:0;

 

viz = (document.layers)?'hide':'hidden';

if (ns) {

for (i = 0; i < dots; i++)

document.write('<layer name=nface'+i+' top=0 left=0 bgcolor=#000099 clip="0,0,3,3"></layer>');

for (i = 0; i < S.length; i++)

document.write('<layer name=nx'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+sCol+'><center>'+S[i]+'</center></font></layer>');

for (i = 0; i < M.length; i++)

document.write('<layer name=ny'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+mCol+'><center>'+M[i]+'</center></font></layer>');

for (i = 0; i < H.length; i++)

document.write('<layer name=nz'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+hCol+'><center>'+H[i]+'</center></font></layer>');

}

else if (ie4){

document.write('<div id="W" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < dots; i++) {

document.write('<div id="face" style="position:absolute;top:0px;left:0px;width:3px;height:3px;font-size:3px;background:#000099"></div>');

}

document.write('</div></div>');

document.write('<div id="X" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < S.length; i++) {

document.write('<div id="x" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+sCol+';text-align:center;padding-top:10px">'+S[i]+'</div>');

}

document.write('</div></div>')

document.write('<div id="Y" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < M.length; i++) {

document.write('<div id="y" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+mCol+';text-align:center;padding-top:10px">'+M[i]+'</div>');

}

document.write('</div></div>')

document.write('<div id="Z" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < H.length; i++) {

document.write('<div id="z" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+hCol+';text-align:center;padding-top:10px">'+H[i]+'</div>');

}

document.write('</div></div>');

}

if (ns) {

window.captureEvents(Event.MOUSEMOVE);

function nsMouse(evnt) {

Ypos = evnt.pageY + 100;

Xpos = evnt.pageX + 100;

}

window.onMouseMove = nsMouse;

}

else if (ie4){

function ieMouse() {

Ypos = event.y + 100;

Xpos = event.x + 100;

}

document.onmousemove = ieMouse;

}

function clock() {

time = new Date ();

secs = time.getSeconds();

sec = -1.57 + Math.PI * secs / 30;

mins = time.getMinutes();

min = -1.57 + Math.PI * mins / 30;

hr = time.getHours();

hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes())

/ 360;

Ybase = 15;

Xbase = 15;

 

if (ns) {

document.layers["nx"+0].visibility = viz;

document.layers["ny"+0].visibility = viz;

document.layers["nz"+0].visibility = viz;

for (i = 0; i < S.length; i++) {

document.layers["nx"+i].top = ay - 12 + (i * Ybase) * Math.sin(sec);

document.layers["nx"+i].left = ax - 12 + (i * Xbase) * Math.cos(sec);

}

for (i = 0; i < M.length; i++) {

document.layers["ny"+i].top = by - 12 + (i * Ybase) * Math.sin(min);

document.layers["ny"+i].left = bx - 12 + (i * Xbase) * Math.cos(min);

}

for (i = 0; i < H.length; i++) {

document.layers["nz"+i].top = cy - 12 + (i * Ybase) * Math.sin(hrs);

document.layers["nz"+i].left = cx - 12 + (i * Xbase) * Math.cos(hrs);

}

for (i = 0; i < dots; ++i) {

document.layers["nface"+i].top = dy - 2 + (70 *

Math.sin(-0.49+dots+i/1.9));

document.layers["nface"+i].left = dx + 4 + (70 *

Math.cos(-0.49+dots+i/1.9));

   }

}

else if (ie4) {

var scrll = document.body.scrollTop;

W.style.pixelTop = scrll;

X.style.pixelTop = scrll;

Y.style.pixelTop = scrll;

Z.style.pixelTop = scrll;

x[0].style.visibility=viz;

y[0].style.visibility = viz;

z[0].style.visibility = viz;

for (i = 0; i < S.length; i++) {

x[i].style.pixelTop = ay - 12 + (i * Ybase) * Math.sin(sec);

x[i].style.pixelLeft = ax - 12 + (i * Xbase) * Math.cos(sec);

}

for (i = 0; i < M.length; i++) {

y[i].style.pixelTop = by - 12 + (i * Ybase) * Math.sin(min);

y[i].style.pixelLeft = bx - 12 + (i * Xbase) * Math.cos(min);

}

for (i = 0; i < H.length; i++) {

z[i].style.pixelTop = cy - 12 + (i * Ybase) * Math.sin(hrs);

z[i].style.pixelLeft = cx - 12 + (i * Xbase) * Math.cos(hrs);

}

for (i = 0; i < dots; ++i) {

face[i].style.pixelTop = dy + 6 + (70 * Math.sin(-0.49 + dots + i /

1.9));

face[i].style.pixelLeft = dx + 4 + (70 * Math.cos(-0.49 + dots + i /

1.9));

      }

   }

}

function MouseFollow() {

ay = Math.round(Ay += ((Ypos) - Ay) * 4 / 15);

ax = Math.round(Ax += ((Xpos) - Ax) * 4 / 15);

by = Math.round(By += (ay - By) * 4 / 15);

bx = Math.round(Bx += (ax - Bx) * 4 / 15);

cy = Math.round(Cy += (by - Cy) * 4 / 15);

cx = Math.round(Cx += (bx - Cx) * 4 / 15);

dy = Math.round(Dy += (cy - Dy) * 4 / 15);

dx = Math.round(Dx += (cx - Dx) * 4 / 15);

clock();

setTimeout('MouseFollow()',10);

}

function StartAll() {

MouseFollow();

}

if (document.layers || document.all) window.onload = StartAll;

//  End -->

</script>

 

0 Comments

Wed

18

Mar

2009

91、查找是星期几

91、查找是星期几

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

var days = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

var mtend = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

var opt = new Array("过去时间","将来时间");

function getDateInfo() {

var y = document.form.year.value;

var m = document.form.month.options[document.form.month.options.selectedIndex].value;

var d = document.form.day.options[document.form.day.options.selectedIndex].value;

var hlpr = mtend[m];

if (d < mtend[m] + 1) {

if (m == 1 && y % 4 == 0) { hlpr++; }

var c = new Date(y,m,d);

var dayOfWeek = c.getDay();

document.form.dw.value = days[dayOfWeek];

if(c.getTime() > new Date().getTime()) {

document.form.time.value = opt[1];

}

else {

document.form.time.value = opt[0];

   }

}

else {

alert("这一天"+months[m]+" "+d+", "+y+"是不存在的.\n请重新选择.");

   }

}

function setY() {

var y = new Date().getYear();

if (y < 2000) y += 1900;

document.form.year.value = y;

}

//  End -->

</script>

<form name="form">

<p><select name="day" size="1">

<option selected value="1">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<option value="11">11</option>

<option value="12">12</option>

<option value="13">13</option>

<option value="14">14</option>

<option value="15">15</option>

<option value="16">16</option>

<option value="17">17</option>

<option value="18">18</option>

<option value="19">19</option>

<option value="20">20</option>

<option value="21">21</option>

<option value="22">22</option>

<option value="23">23</option>

<option value="24">24</option>

<option value="25">25</option>

<option value="26">26</option>

<option value="27">27</option>

<option value="28">28</option>

<option value="29">29</option>

<option value="30">30</option>

<option value="31">31</option>

</select><select name="month" size="1">

<option selected value="0">January</option>

<option value="1">February </option>

<option value="2">March </option>

<option value="3">April </option>

<option value="4">May </option>

<option value="5">June </option>

<option value="6">July </option>

<option value="7">August </option>

<option value="8">September </option>

<option value="9">October </option>

<option value="10">November </option>

<option value="11">December </option>

</select><input type="text" name="year" size="4"> <input type="button"

value="看看这天的信息" name="gdi" onClick="getDateInfo()"></p>

<p>这里显示是星期几:<input type="text" name="dw" size="12">时间状态:<input type="text"

name="time" size="10"></p>

</form>

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad="setY()">

 

0 Comments