网站favicon图标动态效果代码

冬月初五 2020-4-3 4836

<script>
    var favicon_images = [
                    './assets/images/favicon/0.jpg',
                    './assets/images/favicon/1.jpg',
                    './assets/images/favicon/2.jpg',
                    './assets/images/favicon/3.jpg',
                    './assets/images/favicon/4.jpg',
                    './assets/images/favicon/5.jpg'
                ],
    image_counter = 0; // To keep track of the current image
    setInterval(function() {
        $("link[rel='icon']").remove();
        $("link[rel='shortcut icon']").remove();
        $("head").append('<link rel="icon" href="' + favicon_images[image_counter] + '" type="image/jpeg">');
        
      // If last image then goto first image
      // Else go to next image    
      if(image_counter == favicon_images.length -1)
            image_counter = 0;
        else
            image_counter++;
    }, 80);
  </script>

最新回复 (1)
    • 记录·WiKi
      3
        立即登录 立即注册 
返回
文章系网友原创或转载,目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵权行为,请联系我们admin(a)jilu.wiki,我们会及时删除。