ブラウザでの表示 | ソースファイル |
<script language="JavaScript"> <!-- now=new Date() d=now.getDate() m=now.getMonth()+1 y=now.getYear() min=now.getMinutes() hour = now.getHours() sec = now.getSeconds() document.write("今日は"+y+"年"+m+"月"+d+"日です") document.write("現在は"+hour+"時"+min+"分"+sec+"秒です") //--> </script> |
|
<script language="JavaScript"> <!-- document.write("最終更新 " +document.lastModified) //--> </script> |
|
<script language="JavaScript"> <!-- now = new Date(document.lastModified) y = now.getYear() m = now.getMonth() + 1 d = now.getDate() document.write("最終更新 " + y + "年" + m + "月" + d + "日") //--> </script> |
|
<script language="JavaScript"> <!-- function paralympics(day){ today = new Date() lastday = new Date(day) lastday.setYear(today.getYear()) msPerDay = 24 * 60 * 60 * 1000 daysLeft = (lastday.getTime() - today.getTime()) / msPerDay daysLeft = Math.round(daysLeft) - 1 document.write("シドニーパラリンピックまで、あと" + daysLeft +"日") } paralympics("Oct 18,2000") //--> </script> |
|
<form method="post" name="watch"> ただいま<input name="box" size="10">です。 <script language="JavaScript"> <!-- function tokei(){ now = new Date() h = now.getHours() m = now.getMinutes() s = now.getSeconds() if (h < 10) h = "0" + h if (m < 10) m = "0" + m if (s < 10) s = "0" + s document.watch.box.value=h+":"+m+":"+s setTimeout('tokei()', 999) } tokei() // --> </script> </form> |
|
<script language="JavaScript"> <!-- now=new Date() h=now.getHours() if (h >= 0 && h <= 4) { aisatu = "早く寝なさい" } if (h >= 5 && h <=9) { aisatu = "おはよう" } if (h >= 10 && h <=18) { aisatu = "こんにちは" } if (h >= 19 && h <=23) { aisatu = "こんばんは" } document.write(aisatu) // --> </script> |