实现让网页标签页头部有新消息提醒和让网页的Title标题文字滚动显示效果

转自:https://www.cnblogs.com/pipixiaolaohu/p/7890378.html


1.http://www.qdfuns.com/notes/44322/c0f113eae21acef5c8c109408e8be641.html

复制代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <button id='shiftBtn' type="button" name="button">开关</button>
    <script src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script>
    <script type="text/javascript">
    $(function(){
        var timeout=true;
        var count=0;
        var titleOrigin='';
        var running=0;

        $('#shiftBtn').on('click',function(){
            if(count==0){
                titleOrigin=$('title',window.top.document).html();
                $('title',window.top.document).html('【有新提醒】'+titleOrigin);
                count++;
            }
            if(timeout){
                    timeout=false;
            }else{
                    timeout=true;
            }
                        if(running)return;
            time();
        })
        function time()
        {
          running=1;
          if(timeout) {
                $('title',window.top.document).html(titleOrigin);
                count=0;
                running=0;
                return;
            }
          Method();
          setTimeout(time,500); //time是指本身,延时递归调用自己,500为间隔调用时间,单位毫秒
        }
        function Method(){
            var titlePre=$('title',window.top.document).html().match(/\【[\s\S]*\】/)[0];
            var titleafter=$('title',window.top.document).html().replace(titlePre,'');

            if(titlePre=='【有新提醒】'){
                $('title',window.top.document).html('【&emsp;&emsp;&emsp;&emsp;】'+titleafter)
            }else{
                $('title',window.top.document).html('【有新提醒】'+titleafter)
            }
        }

    })
    </script>
</body>

</html>

复制代码

 2.http://www.daimajiayuan.com/sitejs-8083-1.html

复制代码

<!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=utf-8" />
        <title>让网页的Title标题文字滚动显示效果</title>
    </head>

    <body bgcolor="#ffffff" οnlοad="newtext()">
        <script language=javascript>
            var text = document.title
            var timerID

            function newtext() {
                clearTimeout(timerID)
                document.title = text.substring(1, text.length) + text.substring(0, 1)
                text = document.title.substring(0, text.length)
                timerID = setTimeout("newtext()", 100)
            }
        </script>
    </body>

</html>

复制代码

 3.http://www.jb51.net/article/73794.htm

复制代码

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="UTF-8"/>
        <title>JS实现title标题闪烁提示信息</title>
    </head>
    <body>
        <script type="text/javascript">
            _record = 0;
            var myTitle = document.title;

            function titleBlink() {
                _record++;
                if(_record == 3) { //当变量_record累加到3是,将其赋值为1。相当于无限循环。
                    _record = 1;
                }
                if(_record == 1) {
                    document.title = '【  】' + myTitle;
                }
                if(_record == 2) {
                    document.title = '【新消息】' + myTitle;
                }
                setTimeout("titleBlink()", 500); //调节时间,单位毫秒。
            }
            titleBlink();
        </script>
        
    </body>

</html>

复制代码

5.http://www.divcss5.com/jiqiao/j510.shtml  title属性换行

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值