用JavaScript来控制状态栏

来源:互联网  作者:佚名
摘要:1、跳动的文字把以下代码放在head/head之间:script language="JavaScript" ! Hide var speed = 10 var pause = 1500 var timerID = null var b……

5、状态栏跑马灯效果

把以下代码放在<head></head>之间:
<SCRIPT LANGUAGE="JavaScript">
<!--
var speed = 50
var pause = 2000
var timerID = null
var bannerRunning = false
var ar = new Array()
ar[0] = "MESSAGE #1"
ar[1] = "MESSAGE #2"
ar[2] = "MESSAGE #3"
ar[3] = "MESSAGE #4"

var currentMessage = 0
var offset = 0
function stopBanner() {
      if (bannerRunning)
              clearTimeout(timerID)
      bannerRunning = false
}
function startBanner() {
      stopBanner()
      showBanner()
}
function showBanner() {
      var text = ar[currentMessage]
      if (offset < text.length) {
              if (text.charAt(offset) == " ")
                      offset++                       
              var partialMessage = text.substring(0, offset + 1) 
              window.status = partialMessage
              offset++ 
              timerID = setTimeout("showBanner()", speed)
              bannerRunning = true
      } else {
              offset = 0
              currentMessage++
              if (currentMessage == ar.length)
                      currentMessage = 0
              timerID = setTimeout("showBanner()", pause)
              bannerRunning = true
      }
}
// -->
</SCRIPT>
把以下代码放在<body>中:
<body onLoad="startBanner()">

【相关文章】好搜一下
利用 C# 实现任务栏通知窗口

利用 C# 实现任务栏通知窗口

想必大部分网友都使用过QQ、MSN等聊天程序,它们的界面都相当华丽,尤其是当网友…