私は水槽を設計しています。ページの背景全体が水です。5000ミリ秒後に水を青から茶色に変えて一時停止する機能を設定したい。次に、ユーザーはボタンをクリックして「タンクを掃除」し、バックグラウンド変更機能をリセットします。
私が見つけることができる唯一の解決策は、背景を青から緑に変え続けるループです。
var intPgColorIndex = 0;
var arrPgColor = new Array("#999966", "#00ffff" );
function SetPgColor()
{
var PgColor;
intPgColorIndex++;
if (intPgColorIndex >= arrPgColor.length)
{
intPgColorIndex = 0;
}
PgColor = arrPgColor[intPgColorIndex];
if (PgColor = "#999966" ) {
document.body.style.backgroundColor = PgColor;
setTimeout("SetPgColor()", 5000);
}
};