樂多的每月記事 - 部落格

By Hedda
at 2006-12-11T23:37
at 2006-12-11T23:37
Table of Contents
也是下拉式選單
不過是用JavaScript寫的
使用方式只要把剛開始那幾行const變數的值改一改就可以了
function以下就不用管了
---
<script language="JavaScript">
const startYear = 2004; // 開始年份
const startMonth = 10; // 開始月份
const endYear = 2006; // 結束年份
const endMonth = 12; // 結束月份
const account = 'scchiang'; // 你的使用者名稱
const defaultString = '---'; // 一開始顯示的字串
const useChinese = 1; // 用中文就填1, 用英文就填0
function gotoMonthlyArchive(month)
{
if (month != "none") {
var url = "http://blog.roodo.com/" + account + "/archives/" +
month + ".html";
window.open(url, "_self", "");
}
}
const monthStr = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
const monthNum = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11", "12"];
var year = endYear;
var month = endMonth;
var i;
var output = '<select onChange="javascript:
gotoMonthlyArchive(this.value);">';
output += '<option value="none">' + defaultString + '</option>';
output += '<optgroup label="' + year + '">';
while ((year > startYear) || (year == startYear && month >= startMonth)) {
i = month - 1;
output += '<option value="' + year + '-' + monthNum[i] + '">';
if (useChinese) {
output += year + ' 年 ' + month + ' 月';
} else {
output += monthStr[i] + ', ' + year;
}
output += '</option>';
if (month == 1) {
month = 12;
year--;
output += '</optgroup>';
output += '<optgroup label="' + year + '">';
} else {
month--;
}
}
output += '</optgroup>';
output += '</select>';
document.write(output);
</script>
--
不過是用JavaScript寫的
使用方式只要把剛開始那幾行const變數的值改一改就可以了
function以下就不用管了
---
<script language="JavaScript">
const startYear = 2004; // 開始年份
const startMonth = 10; // 開始月份
const endYear = 2006; // 結束年份
const endMonth = 12; // 結束月份
const account = 'scchiang'; // 你的使用者名稱
const defaultString = '---'; // 一開始顯示的字串
const useChinese = 1; // 用中文就填1, 用英文就填0
function gotoMonthlyArchive(month)
{
if (month != "none") {
var url = "http://blog.roodo.com/" + account + "/archives/" +
month + ".html";
window.open(url, "_self", "");
}
}
const monthStr = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
const monthNum = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11", "12"];
var year = endYear;
var month = endMonth;
var i;
var output = '<select onChange="javascript:
gotoMonthlyArchive(this.value);">';
output += '<option value="none">' + defaultString + '</option>';
output += '<optgroup label="' + year + '">';
while ((year > startYear) || (year == startYear && month >= startMonth)) {
i = month - 1;
output += '<option value="' + year + '-' + monthNum[i] + '">';
if (useChinese) {
output += year + ' 年 ' + month + ' 月';
} else {
output += monthStr[i] + ', ' + year;
}
output += '</option>';
if (month == 1) {
month = 12;
year--;
output += '</optgroup>';
output += '<optgroup label="' + year + '">';
} else {
month--;
}
}
output += '</optgroup>';
output += '</select>';
document.write(output);
</script>
--
Tags:
部落格
All Comments
Related Posts
天空的文章寫好了需要更新嗎?

By Quintina
at 2006-12-11T23:05
at 2006-12-11T23:05
樂多的每月記事

By Genevieve
at 2006-12-11T22:04
at 2006-12-11T22:04
樂多的每月記事

By Carol
at 2006-12-11T21:34
at 2006-12-11T21:34
關於blogger文章使用圖片

By Delia
at 2006-12-11T20:25
at 2006-12-11T20:25
無名blog中 回應紀錄的刪除

By Margaret
at 2006-12-11T19:32
at 2006-12-11T19:32