HOME >
JavaScript サンプル集 > 現在の時刻を表示する(1秒おきに)
|
現在の時刻を表示する(1秒おきに)
サンプルソース
<html>
<script language="Javascript">
<!--
function timetest() {
d = new Date();
document.all.txt.value = d.toLocaleString();
window.setTimeout("timetest()", 1000);
}
-->
</script>
<body onload="timetest()">
<input type="text" name="txt" size=40>
</body>
</html>
|
解説
bodyのonloadでtimetest(関数)を呼びだして、textボックスに現在の時刻を表示します。
window.setTimeoutは指定した経過時間後(ミリ秒)、指定した関数を実行します。
サンプル
関連する内容
|
スポンサードリンク
|