語法展示:: http://home.graffiti.net/ghh6654hjf/
請用IE6.0或更新版本觀看語法特效展示
將以下程式碼複製,貼在<head>及</head>標籤之間。
<script language="JavaScript">
<!--
var speed = 30
var pause = 5000
var bannerRunning = false
var ar = new Array()
ar[0] = "我在這裡我在這裡!"
ar[1] = "看到了沒......^_^"
ar[2] = "這個跑馬燈的每個字是慢慢拼湊出來的喔,"
ar[3] = "這種的可不常見吧!"
var message = 0
var state = ""
clearState()
function stopBanner() {
if (bannerRunning)
clearTimeout(timerID)
bannerRunning = false}
function startBanner() {
stopBanner()
showBanner()}
function clearState() {
state = ""
for (var i = 0; i < ar[message].length; ++i) {
state += "0" }}
function showBanner() {
if (getString()) {
message++
if (ar.length <= message)
message = 0
clearState()
timerID = setTimeout("showBanner()", pause)
bannerRunning = true } else {
var str = ""
for (var j = 0; j < state.length; ++j) {
str += (state.charAt(j) == "1") ? ar[message].charAt(j) : " "
}
window.status = str
timerID = setTimeout("showBanner()", speed)
bannerRunning = true }}
function getString() {
var full = true
for (var j = 0; j < state.length; ++j) {
if (state.charAt(j) == 0)
full = false }
if (full)
return true
while (1) {
var num = getRandom(ar[message].length)
if (state.charAt(num) == "0")
break }
state = state.substring(0, num) + "1" + state.substring(num + 1, state.length)
return false}
function getRandom(max) {
return Math.round((max - 1) * Math.random())}
-->
</script>
在 var speed = 30 中修改跑馬燈的速度
在 var pause = 5000 中修改訊息間停留的時間(每1秒=1000)
在 ar[0] = "我在這裡我在這裡!" ar[1] = "看到了沒......^_^" ar[2] = "這個跑馬燈的每個字是慢慢拼湊出來的喔," ar[3] = "這種的可不常見吧!" 中修改要顯示的文字
將以下程式碼複製,貼在插入<body >標籤裡面。
onLoad="startBanner()"
留言列表