2020工业互联网解决方案提供商TOP100
全世界各行各业联合起来,internet一定要实现!
老文章正文

网页特效之文字组合弹出

2004-04-01 eNet&Ciweek

脚本说明:
第一步:把如下代码加入<head>区域中
<script language="javascript">
<!-- Hide this script from old browsers --
var speed = 10
var pause = 1500
var timerID = null
var bannerRunning = false
var ar = new Array()

ar[0] = "欢迎来到魔域http://www.w12345.com网站! "
ar[1] = "欢迎光临网页特效专栏 "
ar[2] = "请多提意见,谢谢! "

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())
}
// -- End Hiding Here -->
</script>

第二步:把如下代码加入<body>区域中
<body bgcolor="#ffffff" onLoad="startBanner()">

相关频道: eNews 老文章

您对本文或本站有任何意见,请在下方提交,谢谢!

投稿信箱:tougao@enet16.com
广告