ソース コード
<html>
<head>
<script language="JavaScript">
timerID = 10;
tm = 10000;
count = tm / 1000 - 1;
function NNCheck(version) {
if((navigator.appName.indexOf('Netscape') >= 0)
&& (version <= parseInt(navigator.appVersion.substring(0, 3)))) {
return true;
} else {
return false;
}
}
function Func() {
ret = setTimeout("location.href = location.href", tm);
return ret;
}
function TimerX() {
status = count--;
}
</script>
</head>
<body onload="ret=Func();timerID=setInterval('TimerX()',1000)">
<script language="JavaScript">
col1 = new Array("#000000", "#808080", "#c0c0c0", "#ffffff",
"#ff0000", "#ffff00", "#00ff00", "#00ffff", "#0000ff", "#ff00ff",
"#800000", "#808000", "#008000", "#008080", "#000080", "#800080");
col2 = new Array("black", "gray", "silver", "white",
"red", "yellow", "lime", "aqua", "blue", "fuchsia",
"maroon", "olive", "green", "teal", "navy", "purple");
if(NNCheck(1)) {
btn = '再読み込み';
} else {
btn = '更新';
}
doc = '<p>' + tm / 1000 + '秒毎に更新されます。<\/p>';
doc += '<p>ブラウザの「' + btn + '」ボタンを押しても更新されます。<\/p>';
num = Math.floor(Math.random() * 16) % 16;
col = col2[num] + ' (' + col1[num].toUpperCase() + ')';
doc += '<p>';
doc += '文 字 色'.fontcolor(col1[num]).fontsize('+5').bold();
doc += '<\/p>';
doc += '<p>現在の色は ' + col + ' です。<\/p>';
doc += '<form name="myForm">';
doc += '<input type="button" name="myButton" value="停止" ';
doc += 'onclick="clearTimeout(ret);clearInterval(timerID);document.myForm.myButton.value=\'!?\'">';
doc += '<\/form>';
doc += '<p>↑このボタンを押すと更新されなくなります。<\/p>';
doc += '<p>ブラウザの「' + btn + '」ボタンを押すと再度更新されるようになります。<\/p>';
document.write(doc);
</script>
</body>
</html>