zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Pjax(InstantClick)常用的重载函数

2023-04-18 14:54:15 时间

Pjax(InstantClick)一般需要重载的函数,希望这篇文章能让大家少浪费点时间

作用pjax采用的是异步请求资源,也就是每次请求数据不是重新获取整个页面的数据而是只会获取容器里面的数据。 所以如果一个函数在容器外面(如多说加载函数),在A页面没有,B又需要的话,那么从A页面进入B页面,这个函数就不会执行(没效果),必须回调这个函数。

添加方法: Pjax一般都有个放回调函数的地方,在你使用的主题设置里看看

Handsome主题为例:

  1. 主题 --> 设置外观 --> Pjax --> PJAX回调函数

以下内容转自QQ爹博客

多说评论

if (typeof DUOSHUO !== 'undefined'){
      DUOSHUO.EmbedThread('.ds-thread');} /

网易云跟贴

if (typeof Tie !== 'undefined') {
      Tie.loader("", true);
}

畅言(代码来自http://www.neurallinker.com/94.misaka

if($("#SOHUCS").length==1){
      window.changyan = undefined;window.cyan = undefined;
      $.getScript("https://changyan.sohu.com/upload/changyan.js", function(){window.changyan.api.config({appid: "你的appid参数",conf: "你的conf参数"});});
}

百度统计

if (typeof _hmt !== 'undefined'){
      _hmt.push(['_trackPageview', location.pathname + location.search]);
}

谷歌统计

if (typeof ga !== 'undefined'){
        ga('send', 'pageview', location.pathname + location.search);
}

piwik统计

 _paq.push(['setDocumentTitle', document.title]);
    _paq.push(['trackPageView']);

SynatxHighlighter代码高亮

 SyntaxHighlighter.highlight();

google code prettify

if (typeof prettyPrint !== 'undefined'){
      prettyPrint();
}

MathJax

if (isInitialLoad === false) {
    if (typeof MathJax !== 'undefined'){
      MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}

Prism.js语法高亮

if (typeof Prism !== 'undefined') {
      Prism.highlightAll(true,null);
}

欢迎补充

版权属于:Xcnte' s Blog(除特别注明外) 本文链接:https://www.xcnte.com/archives/461/ 本站文章采用 知识共享署名4.0 国际许可协议 进行许可,请在转载时注明出处及本声明!