怎麼做?
Step1:進Blogger管理畫面-->版面配置-->網頁元素
Step2:新增「新增小工具」-->「HTML Javascript」
Step3:把以上原始碼貼上去,紅色字體處調整一下即可!
<script language="JavaScript">
<!--年齡計算語法_開始-->
RightNow = new Date();
var year = RightNow.getFullYear();
var month = RightNow.getMonth();
var day = RightNow.getDate();
var t_yy = 0;
var t_mm = 0;
var t_dd = 0;
var b_yy = '1975';
var b_mm = '12';
var b_dd = '28';
t_yy = year - b_yy - 1;
if ( month + 1 > b_mm){
t_mm = month - b_mm ;
t_yy++;
}else
t_mm = 12 - b_mm + month;
if (day > b_dd){
t_dd = day - b_dd;
t_mm++;
}else
t_dd = daysInMonth(month, year) - b_dd + day;
if (t_dd > daysInMonth(month, year)-1){
t_dd = 0;
t_mm++;
}
if (t_mm > 11){
t_mm = 0;
t_yy++;
}
document.write('<center>' + 'Juma 已經<b>');
if (t_yy > 0)
document.write(" " + '<b><font color="red">' + t_yy + '</font></b>' + " 歲 ");
if (t_mm > 0)
document.write('<b><font color="red">' + t_mm + '</font></b>' + " 個月");
if (t_dd > 0)
document.write(" 又 " + '<b><font color="red">' + t_dd + '</font></b>' + " 天 " + '</center>');
//****** function set ******
function arrayOfDayInMonths(isLeapYear)
{ this[0] = 31;
this[1] = 28;
if (isLeapYear)
this[1] = 29;
this[2] = 31;
this[3] = 30;
this[4] = 31;
this[5] = 30;
this[6] = 31;
this[7] = 31;
this[8] = 30;
this[9] = 31;
this[10] = 30;
this[11] = 31;
}
function daysInMonth(month, year)
{ var isLeapYear = ((( year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
var monthdays = new arrayOfDayInMonths(isLeapYear);
return monthdays[month];
}
<!--年齡計算語法_結束-->
</script>
沒有留言:
張貼留言