动态标题
效果图如下:
实现方法,引入 js 文件,在主题文件下的/source/js/
下新建FunnyTitle.js
,然后在添加到themes/matery/layout/layout.ejs
或者添加到themes/matery/layout/_partial/head.ejs
,其代码如下:
<!--浏览器搞笑标题--> var OriginTitle = document.title; var titleTime; document.addEventListener('visibilitychange', function () { if (document.hidden) { $('[rel="icon"]').attr('href', "https://cdn.jsdelivr.net/gh/Yafine/cdn@2.5/source/favicon.png"); document.title = 'ヽ(●-`Д´-)ノ你要玩捉迷藏嘛'; clearTimeout(titleTime); } else { $('[rel="icon"]').attr('href', "https://cdn.jsdelivr.net/gh/Yafine/cdn@2.5/source/favicon.png"); document.title = 'ヾ(Ő∀Ő3)ノ好哦!' + OriginTitle; titleTime = setTimeout(function () { document.title = OriginTitle; }, 2000); } });
|
或者直接在themes/matery/layout/layout.ejs
文件中添加如下代码:
<script type="text/javascript"> var OriginTitile=document.title,st; document.addEventListener("visibilitychange",function(){ document.hidden?(document.title="ヽ(●-`Д´-)ノ你要玩捉迷藏嘛",clearTimeout(st)):(document.title="(Ő∀Ő3)ノ好哦!",st=setTimeout(function(){document.title=OriginTitile},3e3)) }) </script>
|