《HTML5+CSS3+JavaScript 从入门到精通(标准版)》学习笔记 (二)

这是一个应用的例子,学以致用嘛

<!--这些代码我就直接放在了博客园的"页首Html代码"中,用于自定义博客,效果就是页面左上角的白色文字-->
<p>
    <a href="http://justsong.xyz/archives/"><!--指向我的简陋的个人网站的链接,如果你有兴趣自己也搞一个,这个是教程:  http://justsong.xyz/2018/06/09/hello-world/ -->
        <font size="3" color="white" face="verdana" id="text">
            I HOPE IT IS USERFUL TO YOU
        </font>
    </a>
</p>
<script>//需要向博客园申请JavaScript权限
    var i = 0;
    setInterval("changeText()", 1200);//每1.2秒调用changText()函数一次
    function changeText() {
        var element = document.getElementById("text");//如函数名
        var textArray = ['CLICK IT IF YOU WANT', 'HERE IS MY PERSON WEBSITE', 'WELCOME YOU TO VISITE', 'I HOPE IT IS USERFUL TO YOU',"I HOPE THIS FLASHING WORDS DON'T MAKE YOU NAUSEOUS"];//这是一个数组
        if (i == textArray.length) {
            i = 0;
        }
        else {
            element.innerHTML = textArray[i++];//改变组件的HTML代码
        }
    }
</script>

升级版

<p>
    <a href="http://justsong.xyz/archives/">
        <font size="3" color="white" face="verdana" id="text">I HOPE IT IS USERFUL TO YOU</font>
    </a>
</p>
<script>

    var i = 0;
    if(Math.round(Math.random())==0){
        if (Math.round(Math.random()) == 0) {
            setInterval("changeText()", 1200);
        }
        else {
            setInterval("changeText2()", 500);
        }

    }
    else{
         setInterval("changeText2()", 300);
    }

    function changeText() {
        var element = document.getElementById("text");
        var textArray = ['CLICK IT IF YOU WANT', 'HERE IS MY PERSON WEBSITE', 'WELCOME YOU TO VISITE MY WEBSITE', 'I HOPE IT IS USERFUL TO YOU', "I HOPE THIS FLASHING WORDS DON'T MAKE YOU NAUSEOUS"];
        if (i == textArray.length) {
            i = 0;
        }
        else {
            element.innerHTML = textArray[i++];
        }
    }

    function changeText2() {
        var element = document.getElementById("text");
        var textArray = ['145.256.256.89 login: root'
        , 'Password: '
        ,'Password: *'
        , 'Password: **'
        , 'Password: ***'
        , 'Password: ****'
        , 'Password: *****'
        , 'Password: ******'
        , 'Password: *******'
        , 'Password: ********'
        , 'Password: *********'
        , 'Password: **********'
        , 'Password: ***********'
        ,'FAILED,TRY AGAIN:'
        , 'Password: '
        , 'Password: *'
        , 'Password: **'
        , 'Password: ***'
        , 'Password: ****'
        , 'Password: *****'
        , 'Password: ******'
        , 'Password: *******'
        , 'Password: ********'
        , 'Password: *********'
        , 'Password: **********'
        , 'Password: ***********'
        ,'root@145.256.256.89: CONNECT TO SERVER'
        , 'root@145.256.256.89: FAILED'
        , 'root@145.256.256.89: TRY AGAIN, REST TIME: 3'
        , 'root@145.256.256.89: TRY AGAIN, REST TIME: 2'
        , 'root@145.256.256.89: TRY AGAIN, REST TIME: 1'
        , 'root@145.256.256.89: CONNECTED'
        , 'root@145.256.256.89: CLICK HERE TO SEE DETILED INFORMATION'
        , 'root@145.256.256.89: CLICK HERE TO SEE DETILED INFORMATION'
        , 'root@145.256.256.89: CLICK HERE TO SEE DETILED INFORMATION'
        ,'root@145.256.256.89: AN UNEXPECTED ERROR OCCURED, PLEASE VISITE http://justsong.xyz FOR MORE INFORMATION'
        , 'root@145.256.256.89: AN UNEXPECTED ERROR OCCURED, PLEASE VISITE http://justsong.xyz FOR MORE INFORMATION'
        , 'root@145.256.256.89: AN UNEXPECTED ERROR OCCURED, PLEASE VISITE http://justsong.xyz FOR MORE INFORMATION'
        , 'root@145.256.256.89: AN UNEXPECTED ERROR OCCURED, PLEASE VISITE http://justsong.xyz FOR MORE INFORMATION'
        ];
        if (i == textArray.length) {
            i = 0;
        }
        else {
            element.innerHTML = textArray[i++];
        }
    }
</script>
posted @ 2018-06-18 15:21  JustSong  阅读(1769)  评论(0编辑  收藏  举报