zoukankan      html  css  js  c++  java
  • JS--在标题中实现跑马灯的效果

    	var time=null;
    	timer();
    	function timer(){
    		$(function(){
                var title=$("title").html();
                var temptitle=title;
                var length=title.length;
                time=setInterval(function(){
                    temptitle=temptitle.concat(temptitle.charAt(0));
                    length=temptitle.length;
                    temptitle=temptitle.substring(1,length);
                    $("title").html(temptitle);
                }, 500);
            });
    	}
    	document.addEventListener('visibilitychange', function () {
    	<!--判断如果离开页面时,title变化并清除在页面时跑马灯效果-->
    		if (document.visibilityState == 'hidden') {
    			normal_title = document.title;
    			document.title = '客官请留步...';
    			clearInterval(time)
    		} else{
    	<!--如果在当前页面时,title变化,执行定时器-->
    			document.title = normal_title;
    			timer();
    		} 
    	});
    
  • 相关阅读:
    字符串类型
    数据类型之整型
    数据类型
    两个版本的区别
    变量
    DHCP
    MySQL数据库编译及入门
    NFS网络文件系统
    Rsync 数据同步
    互联网数据分享平台
  • 原文地址:https://www.cnblogs.com/cyapi/p/15365797.html
Copyright © 2011-2022 走看看