闪烁的霓虹灯

- 中国WEB开发者网络 (http://www.webasp.net)
-- 网页特效 (http://www.webasp.net/javascript/)
--- 闪烁的霓虹灯 (http://www.webasp.net/javascript/1/584.htm)
-- 发布日期: 2005-06-20
<!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! -->
<!-- 要实现此效果需要 2 个步骤: -->

<!-- 第 1 步: -->
<!-- 把<BODY>中的属性代码改为: -->

<BODY bgcolor="#fef4d9" onLoad="animate()">



<!-- 第 2 步: -->
<!-- 把下面的代码加到<BODY></BODY>区域中: -->

<SCRIPT LANGUAGE="JavaScript">

<!--


// create row of radio buttons
lay(20)

// set index of lamp to start animation
var current = 0

// set speed (pause in milliseconds between each movement)
var speed = 1000

function lay(num) {
// assign "greater than" character to variable
var gt = unescape("%3e")

// open form
document.write("<FORM NAME='animation'" + gt)

// use loop to lay radio buttons down (all buttons in same group)
for (var i = 0; i < num; ++i) {
document.write("<INPUT TYPE='radio' NAME='lamps'" + gt)
}

// close form
document.write("</FORM" + gt)
}

function animate() {
// click next radio button
document.animation.lamps[current].click()

// if radio button is the last one reset variable to 0 (otherwise increment)
current = (current == document.animation.lamps.length - 1) ? 0 : ++current

// recursive call after speed milliseconds
timerID = setTimeout("animate()", speed)
}

// -->

</SCRIPT>


webasp.net