欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解如何讓InstantClick兼容MathJax、百度統(tǒng)計(jì)等

 更新時(shí)間:2017年09月12日 16:19:38   作者:zhiqiang  
本篇文章主要介紹了如何讓InstantClick兼容MathJax、百度統(tǒng)計(jì)等,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

之前有網(wǎng)友提及博客上的LaTex(由MathJax實(shí)現(xiàn))壞掉了,其原因是這里使用了instantclick,以達(dá)到網(wǎng)頁(yè)秒開的效果。但由于instantclick不會(huì)重新運(yùn)行位于head部分的JavaScript代碼,而很多工具性軟件,比如MathJax、百度統(tǒng)計(jì)、Google Analytics、Google Code Prettify等軟件都是直接將JS文件插入到head區(qū)域。這導(dǎo)致這些工具在instantclick點(diǎn)擊后失效,需要重新配置。

配置并不復(fù)雜,這些工具本身的代碼不用做任何修改,該怎么放還怎么放。但在InstantClick.init();之前添加以下代碼:

<script data-no-instant>
InstantClick.on('change', function(isInitialLoad) {
 if (isInitialLoad === false) {
  if (typeof MathJax !== 'undefined') // support MathJax
   MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
  if (typeof prettyPrint !== 'undefined') // support google code prettify
   prettyPrint();
  if (typeof _hmt !== 'undefined') // support 百度統(tǒng)計(jì)
   _hmt.push(['_trackPageview', location.pathname + location.search]);
  if (typeof ga !== 'undefined') // support google analytics
    ga('send', 'pageview', location.pathname + location.search);
 }
});
InstantClick.init();
</script>

這段代碼的含義是每次頁(yè)面重載時(shí),通過直接的函數(shù)調(diào)用來實(shí)現(xiàn)MathJax、百度統(tǒng)計(jì)、Google Code Prettify、Google Analytics的重新運(yùn)行。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關(guān)文章

最新評(píng)論