多變的背景
將下列程式碼複製至<head>程式碼</head>區內。
<script language="JavaScript"> var pos = 10; function initArray() { this.length = initArray.arguments.length; for (var i = 0; i < this.length; i++) { this[i] = initArray.arguments[i]; } } var col=new initArray("4b","5b","8b","8b"); col[0] = "#FFFFE0"; //修改背景變化顏色 col[1] = "#FFF0F5"; //修改背景變化顏色 col[2] = "#FFE1FF"; //修改背景變化顏色 col[3] = "#FFC125"; //修改背景變化顏色 col[4] = "#FFBBFF"; //修改背景變化顏色 col[5] = "#FF83FA"; //修改背景變化顏色 col[6] = "#F5FFFA"; //修改背景變化顏色 col[7] = "#E0FFFF"; //修改背景變化顏色 col[8] = "#C0FF3E"; //修改背景變化顏色 col[9] = "#71C671"; //修改背景變化顏色 function chgCol() { pos++; if (pos<0||pos>9) { pos = 0; } document.bgColor = col[pos]; setTimeout("chgCol()",5000); /* Change above set to every 10 seconds (1000 = 1 sec) If you wish to speed it up, lower the number. To slow it down, raise the number. */ } var yourwords = "多變的背景";var buffer1=" ";var buffer2=" ";var message1=buffer1+yourwords+buffer2;var dir = "left";var speed =150;function pingpong(){if (dir == "left") { message2=message1.substring(2,message1.length)+" "; window.status=message2; setTimeout("pingpong();",speed); message1=message2; if (message1.substring(0,1) == "*") dir="right"; }else { message2=" "+message1.substring(0,message1.length-2); window.status=message2; setTimeout("pingpong();",speed); message1=message2; if (message1.substring(message1.length-1,message1.length) == "*") dir="left"; }} // --> </script> |
將下列程式碼複製至<body 程式碼>的標籤之中。
onload="chgCol(); pingpong();" |