返回列表 发帖

js困或!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                                <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
                                <title>Untitled Document</title>
                                <script language="JavaScript">
                                        function assignArray(text,delay)
                                        {
                                                this.text=text
                                                this.delay=delay
                                        }
                                        function createArray()
                                        {
                                                //修改下面的渐变颜色代码
                                                fadecolor=new Array("#000000","#333333","#666666","#999999","#CCCCCC","#FFFFFF")//显示的颜色
                                                msg=new Array()
                                                msg[0]=new assignArray("中国共产党万岁",1000)//修改显示的文字
                                                msg[1]=new assignArray("为人民服务",1000)//修改显示的文字
                                                msg[2]=new assignArray("感恩的心",1000)//修改显示的文字
                                                msg[3]=new assignArray("难忘今宵",1000)//修改显示的文字
                                                setTimeout("typeIt()", 1000)
                                        }
                                        var msgNo=0
                                        var character=1
                                        var colorNo=0
                                        var fixColor=1
                                        var colorCheck=0
                                        function typeIt()
                                        {
                                                var insertHTML=""
                                                if(msgNo <= msg.length-1)
                                                {
                                                        if(character <= msg[msgNo].text.length || colorCheck < msg[msgNo].text.length)
                                                        {
                                                                colorCheck=0
                                                                for(var charCheck=0; charCheck<character; charCheck++,colorNo--,fixColor--)
                                                                {
                                                                        if(fixColor>5)colorNo=5
                                                                        if(colorNo==5)colorCheck+=1
                                                                        insertHTML += '<SPAN style="font-family:Arial Black; font-size:50pt; color:'+fadecolor[colorNo]+'">' + msg                        [msgNo].text.substring(charCheck, charCheck+1) + '</SPAN>'
                                                                }
                                                                document.getElementById("typeWriter").innerHTML=insertHTML
                                                                setTimeout("typeIt()", 50)
                                                                character++
                                                                colorNo=character-1
                                                                fixColor=character
                                                        }
                                                        else
                                                        {
                                                                character=1
                                                                colorNo=character-1
                                                                fixColor=character
                                                                setTimeout("typeIt()", msg[msgNo].delay)
                                                                msgNo++
                                                        }
                                                }
                                        }
                                </script>
                </head>
                <body bgcolor="#000000" onLoad="createArray()" text="#ffffff">
                                <div ID="typeWriter" style="position:absolute; left:200; top:10; width:700"></div>
                </body>
</html>
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友

谁能帮我解决一下?

TOP

循环里搞不明白

TOP

楼主问题的是其中;
for(var charCheck=0; charCheck<character; charCheck++,colorNo--,fixColor--)
fixcolor有什么用

TOP

HI,你要说一下这是第几章第几页,我看要实现的是什么效果?

TOP

第一章的1.5  拉幕效果.html

TOP

回复 5# 专业解答

Javascript网页特效实例大全    第一章:1.5  拉幕效果.html

TOP

也可以把我上面的代码复制来保存为html文件来测试

TOP

因为我这边没有书,我测试了下效果,在循环中去掉colorNo--,fixColor--是一样的,原来的代码现在测试已经不行了,可以把设计这俩变量的相关代码都去掉,再调试下看看效果是否不同。

TOP

返回列表