WordPress设置网站动态标题[WP教程]

Put blinders on to those things that conspire to hold you back, especially the ones in your own head.
不要去想那些阻碍你的事,尤其是那些自己想象出来的事

【活动】:会员128元永久会员早开早划算!

WordPress设置网站动态标题[WP教程]

前言

我们经常逛别人的网站,有些网站当我们离开该页面浏览其他页面的时候,我们在离开的页面上面会看到比如本站的“你别走吖 Σ(っ °Д °;)っ”这样的字样,当我们点回来的时候页面上面会看到“(/≧▽≦/)你又回来了!”的字样。那么我们如何实现呢?其实很简单,只需一句javascript语句即可实现。请看下面的教程。

食用教程

  • 以子比主题最新版为例)在后台主题设置—>自定义代码—>自定义javascript代码把下面的代码添加到里面即可实现。
//动态标题 var OriginTitile = document.title,titleTime;document.addEventListener("visibilitychange",function() {    if (document.hidden) {        document.title = "你别走吖 Σ(っ °Д °;)っ";        clearTimeout(titleTime)    } else {        document.title = "(/≧▽≦/)你又回来啦! " ;        titleTime = setTimeout(function() {            document.title = OriginTitile        },        2000)    }});

注:代码中“你别走吖 Σ(っ °Д °;)っ”和“(/≧▽≦/)你又回来啦!”可自行修改成自己喜欢的标题文字。

  • 如果你的网站主题设置没有自定义javascript代码这个框的话,若有自定义头部HTML代码的话,把下面的代码添加到里面也可实现。
  • 或者在首页文件位于“</hesd>”标签之前添加下面的代码也可以。
<script type="text/javascript">      /*  动态标题*/     var OriginTitile = document.title,      titleTime;     document.addEventListener("visibilitychange",     function() {      if (document.hidden) {        document.title = "你别走吖 Σ(っ °Д °;)っ";        clearTimeout(titleTime)    } else {        document.title = "(/≧▽≦/)你又回来啦!" ;        titleTime = setTimeout(function() {            document.title = OriginTitile        },        2000)    }    });    </script>

注:代码中“你别走吖 Σ(っ °Д °;)っ”和“(/≧▽≦/)你又回来啦!”可自行修改成自己喜欢的标题文字。

效果截图

WordPress设置网站动态标题[WP教程]
动态标题
WordPress设置网站动态标题[WP教程]
------本页已结束,新年特惠限时98元尊贵特权------

感谢您的来访,获取更多精彩文章请收藏本站。

Put blinders on to those things that conspire to hold you back, especially the ones in your own head.
不要去想那些阻碍你的事,尤其是那些自己想象出来的事
© 版权声明
THE END
点赞15打赏 分享
Nothing is more terrible than ignorance in action.
最可怕的事莫过于无知而行动
评价 抢沙发

请登录后发表评论

    暂无评论内容