js-网页title标题文字滚动显示效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>感谢啊实打实大所大所大所大所大大奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥</title>
</head>
<script>
    var text = document.title;  //定义文章的title
    var timerID;    //定义时间变量
    function newtext() {    //定义函数
        clearTimeout(timerID);  //清除定时器
        document.title = text.substring(1, text.length) + text.substring(0, 1); //substring()方法用于提取字符创中介于两个指定下标之间的字符
        text = document.title.substring(0, text.length);
        timerID = setTimeout("newtext()", 100)
    }
</script>
<body onload="newtext()">
    <br>预览效果请看标题栏 ↑<br>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_40002964/article/details/88099583
今日推荐