disqus不起作用

时间:2012-12-10 22:42:16

标签: javascript disqus

我已经正确完成了所有步骤,但无法在我的网站上运行disqus。

我的网站是http://www.lookbookcookbook.com,我使用了以下代码:

<b:if cond='data:blog.pageType == &quot;item&quot;'>

    <b:includable id='main'>
        <script type='text/javascript'>
            var disqus_shortname = 'lookbookcookbook';
            var disqus_blogger_current_url = "<data:blog.canonicalUrl/>";
            if (!disqus_blogger_current_url.length) {
                disqus_blogger_current_url = "<data:blog.url/>";
            }
            var disqus_blogger_homepage_url = "<data:blog.homepageUrl/>";
            var disqus_blogger_canonical_homepage_url = "<data:blog.canonicalHomepageUrl/>";
        </script>
        <b:if cond='data:blog.pageType == "item"'>
            <style type='text/css'>
                #comments {display:none;}
            </style>
            <script type='text/javascript'>
                (function() {
                    var bloggerjs = document.createElement('script');
                    bloggerjs.type = 'text/javascript';
                    bloggerjs.async = true;
                    bloggerjs.src = 'http://'+disqus_shortname+'.disqus.com/blogger_item.js';
                    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(bloggerjs);
                })();
            </script>
        </b:if>
            <style type='text/css'>
                .post-comment-link { visibility: hidden; }
            </style>
            <script type='text/javascript'>
            (function() {
                var bloggerjs = document.createElement('script');
                bloggerjs.type = 'text/javascript';
                bloggerjs.async = true;
                bloggerjs.src = 'http://'+disqus_shortname+'.disqus.com/blogger_index.js';
                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(bloggerjs);
            })();
            </script>
    </b:includable>

1 个答案:

答案 0 :(得分:0)

修改

实际上看起来你看到了这里描述的问题:https://productforums.google.com/d/msg/blogger/eBB8uKXs54w/Ljce-6Nh72cJ

我们在此处编写了有关如何手动安装Blogger小工具的文档,这有助于您解决此问题:http://help.disqus.com/customer/portal/articles/888340

原始答案

这不加载,因为标签的变量(例如disqus_blogger_current_url)正在按字面读取而不是填入适当的值。这意味着,不是您的博客URL被发送到Disqus,它实际上是发送<data:blog.canonicalUrl/>

要解决这个问题,你需要确保输入解码的引号字符,所以整个事情看起来像这样:

<b:includable id='main'>
        <script type='text/javascript'>
            var disqus_shortname = &#39;lookbookcookbook&#39;;
            var disqus_blogger_current_url = &quot;<data:blog.canonicalUrl/>&quot;;
            if (!disqus_blogger_current_url.length) {
                disqus_blogger_current_url = &quot;<data:blog.url/>&quot;;
            }
            var disqus_blogger_homepage_url = &quot;<data:blog.homepageUrl/>&quot;;
            var disqus_blogger_canonical_homepage_url = &quot;<data:blog.canonicalHomepageUrl/>&quot;;
        </script>
        <b:if cond='data:blog.pageType == &quot;item&quot;'>                        
            <style type='text/css'>
                #comments {display:none;}
            </style>
            <script type='text/javascript'>
                (function() {
                    var bloggerjs = document.createElement(&#39;script&#39;);
                    bloggerjs.type = &#39;text/javascript&#39;;
                    bloggerjs.async = true;
                    bloggerjs.src = &#39;http://&#39;+disqus_shortname+&#39;.disqus.com/blogger_item.js&#39;;
                    (document.getElementsByTagName(&#39;head&#39;)[0] || document.getElementsByTagName(&#39;body&#39;)[0]).appendChild(bloggerjs);
                })();
            </script>
        </b:if>
            <style type='text/css'>
                .post-comment-link { visibility: hidden; }
            </style>
            <script type='text/javascript'>
            (function() {
                var bloggerjs = document.createElement(&#39;script&#39;);
                bloggerjs.type = &#39;text/javascript&#39;;
                bloggerjs.async = true;
                bloggerjs.src = &#39;http://&#39;+disqus_shortname+&#39;.disqus.com/blogger_index.js&#39;;
                (document.getElementsByTagName(&#39;head&#39;)[0] || document.getElementsByTagName(&#39;body&#39;)[0]).appendChild(bloggerjs);
            })();
            </script>
    </b:includable>