JavaScript Source Code 3000: Clocks: Current Week
Current Week
Displays the date the current week starts on. Useful if you want a new link each week or just to show the first day of the current week.
document.write(link);
// or you can use
// document.write(week)
// or
// document.write(page)
JavaScript Source Code 3000: Clocks: Current Week
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL CURRENT WEEK:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Mark McCain (sub235k@worldnet.att.net) -->
<! >
<! >
<!-- Begin
page_extension = ".html";
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1;
var year = today.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
var offset = today.getDay();
var week;
if(offset != 0) {
day = day - offset;
if ( day < 1) {
if ( month == 1) day = 31 + day;
if (month == 2) day = 31 + day;
if (month == 3) {
if (( year == 00) || ( year == 04)) {
day = 29 + day;
}
else {
day = 28 + day;
}
}
if (month == 4) day = 31 + day;
if (month == 5) day = 30 + day;
if (month == 6) day = 31 + day;
if (month == 7) day = 30 + day;
if (month == 8) day = 31 + day;
if (month == 9) day = 31 + day;
if (month == 10) day = 30 + day;
if (month == 11) day = 31 + day;
if (month == 12) day = 30 + day;
if (month == 1) {
month = 12;
year = year - 1;
}
else {
month = month - 1;
}
}
}
week = month + "-" + day + "-" + year; // i.e. 10-31-99
page = week + page_extension; // i.e. 10-31.99.html
link = "<a href='" + page + "'>Page of the Week</a>"; // link to 10-31-99.html
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<script>
document.write(link);
// or you can use
// document.write(week)
// or
// document.write(page)
</script>
<!-- Script Size: 1.75 KB -->
Wyszukiwarka
Podobne podstrony:
Currencycurrency 2CurrentHelperChristie Kelley A Week of Pleasure (html)141027 Terminology week 1Blade sections for wind turbine and tidal current turbine applications—current status and future chacurrencyfunction currentcurrent limitationsTraining Lab Week 4function xml get current byte indexCurrentOperationsTrading Forex trading strategies Cashing in on short term currency trendsfunction xml get current column numberfunction xml get current byte indexCurrentOperationswięcej podobnych podstron