時間按鈕
- Internet Explorer 6.0
- Internet Explorer 7.0
- Internet Explorer 8.0
- Mozilla Firefox 2.0
- Mozilla Firefox 3.0
- Google Chrome
- Safari 3.1
- Opera 9.5
- 時間按鈕 - 在按鈕上顯示出現在的時間。
- 語法總長度:700 字元
<script type="text/javascript"><!--
function clock() {
today = new Date();
hrNow = today.getHours();
mnNow = today.getMinutes();
scNow = today.getSeconds();
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 (mnNow <= 9) {min = "0" + mnNow;} else {min = mnNow;}
if (scNow <= 9) {secs = "0" + scNow;} else {secs = scNow;}
yudan = hour + ":" + min + ":" + secs + ap;
document.form.button.value = yudan;
setTimeout("clock()", 1000);}
document.write("<form name=\"form\"><input type=\"button\" value=\"\" name=\"button\" /><\/form>");
clock();
// --></script>
- 可將第 7 至 10 行的 "AM" 和 "PM" 改成 "上午" 和 "下午"