Meta tags 无法为facebook评论设置管理员

Meta tags 无法为facebook评论设置管理员,meta-tags,facebook-comments,Meta Tags,Facebook Comments,我们的网站上有一个关于facebook评论的奇怪问题。脸谱刮板似乎错误地解析了(至少一个)我们的网页,因此它没有利用管理员来缓和评论 如果您转到此链接: 和查看源代码,您将看到我们在头部有适当的标记,包括一个用于fb:admins的标记。如果我用那个帐号登录facebook,我就没有版主的选择 通过facebook对象调试器运行页面,我得到一个错误,我们在主体中有元标记。具体而言,此错误: Meta Tags In Body: You have tags ouside of your . T

我们的网站上有一个关于facebook评论的奇怪问题。脸谱刮板似乎错误地解析了(至少一个)我们的网页,因此它没有利用管理员来缓和评论

如果您转到此链接:

和查看源代码,您将看到我们在头部有适当的标记,包括一个用于fb:admins的标记。如果我用那个帐号登录facebook,我就没有版主的选择

通过facebook对象调试器运行页面,我得到一个错误,我们在主体中有元标记。具体而言,此错误:

Meta Tags In Body:  You have tags ouside of your . This is either because 
your was malformed and they fell lower in the parse tree, or you accidentally
put your Open Graph tags in the wrong place. Either way you need to fix it 
before the tags are usable.
查看页面底部的略过的URL,我看到facebook已经“重组”了我们的html,并将元标记从头部放入身体


有人知道这是什么原因吗?我想也许我们在页面的某个地方有一些格式不正确的html,这会把所有东西都扔掉,但是我检查了该页面的html,它看起来不错。这里还有什么我遗漏的吗?

通过validator.w3.org运行您的URL会显示一些警告标志:

Line 77, Column 14: document type does not allow element "noscript" here; assuming missing "object" start-tag
Line 154, Column 699: document type does not allow element "meta" here
我能够将(潜在)问题缩小到您页面中的以下几行:

document.write('<a href="' + OAS.config.url + 'click_nx.ads/' + OAS.config.sitepage + '/1' + OAS.config.rns + '@' + OAS.config.listpos + '!' + pos + '?' + OAS.config.query + '" target=' + OAS.config.target + '>');
document.write('<img src="' + OAS.config.url + 'adstream_nx.ads/' + OAS.config.sitepage + '/1' + OAS.config.rns + '@' + OAS.config.listpos + '!' + pos + '?' + OAS.config.query + '" border=\"0\" /></a>');
此外,我认为使用document.write()插入DOM是不好的(因为它会导致页面呈现阻塞)。 您可以改为使用js对象和DOM操作吗

FB获取您的URL后,会通过DOM解析器运行该URL,当遇到那些document.write()行时,该解析器可能会阻塞。事实上,这些线路有一个

它产生了错误:

Unexpected end tag : a in /home/dlee/tmp/tmp.html, line: 54
Unexpected end tag : head in /home/dlee/tmp/tmp.html, line: 183
htmlParseStartTag: misplaced <body> tag in /home/dlee/tmp/tmp.html, line: 184
意外结束标记:在/home/dlee/tmp/tmp.html中,第54行
意外结束标记:head-in/home/dlee/tmp/tmp.html,第183行
htmlParseStartTag:home/dlee/tmp/tmp.html中的标签放错位置,第184行
其中tmp.html是保存到文件中的页面html。 第54行是前面提到的document.write()行


让我知道是否有任何上述结果正在进行,我将相应地编辑此答案。

因此,问题最终在于头部嵌套了一个
,它试图为未启用javascript的浏览器添加一个跟踪像素,作为我们使用的广告服务的一部分

从facebook给我们的“他们如何看待你的页面”的输出来看,问题应该是显而易见的。正文紧跟在脚本之后,但紧跟在标记开始的位置之前。显然,当facebook解析器在头部看到一个应该在身体中的元素时,它会感到异常,因此它会立即在那里启动身体

。。。facebook输出

        console.log(OAS);
    })();
</script><!-- End OAS Setup --><!-- Begin comScore Tag --><script>
      var _comscore = _comscore || [];
      _comscore.push({ c1: "2", c2: "8428430" });
      (function() {
        var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
        s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
        el.parentNode.insertBefore(s, el);
      })();
    </script>
</head>
<body>
<noscript>

    </noscript>
    <!-- End comScore Tag -->
console.log(OAS);
})();
var _comscore=_comscore | |[];
_comscore.push({c1:“2”,c2:“8428430”});
(功能(){
var s=document.createElement(“脚本”),el=document.getElementsByTagName(“脚本”)[0];s.async=true;
s、 src=(document.location.protocol==“https:?”https://sb“:“http://b”)+”.scorecardresearch.com/beacon.js”;
el.parentNode.insertBefore(s,el);
})();
。。。我们的html

<head>   
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <asp:PlaceHolder id="OASHeader" runat="server" />

    <!-- Begin comScore Tag -->
    <script type="text/javascript">
      var _comscore = _comscore || [];
      _comscore.push({ c1: "2", c2: "8428430" });
      (function() {
        var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
        s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
        el.parentNode.insertBefore(s, el);
      })();
    </script>    
    <!-- End comScore Tag -->
    <noscript>
        <img src="http://b.scorecardresearch.com/p?c1=2&c2=8428430&cv=2.0&cj=1" alt="" />
    </noscript>

    <script type="text/javascript">
    ....
    <body>
    ....

var _comscore=_comscore | |[];
_comscore.push({c1:“2”,c2:“8428430”});
(功能(){
var s=document.createElement(“脚本”),el=document.getElementsByTagName(“脚本”)[0];s.async=true;
s、 src=(document.location.protocol==“https:?”https://sb“:“http://b”)+”.scorecardresearch.com/beacon.js”;
el.parentNode.insertBefore(s,el);
})();
....
....

所以在将来,无效的头部元素肯定会导致这个问题。

thx的建议,它实际上让我走上了正确的轨道。请参阅我的帖子以获得答案。很好的查找和后续帖子!
<head>   
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <asp:PlaceHolder id="OASHeader" runat="server" />

    <!-- Begin comScore Tag -->
    <script type="text/javascript">
      var _comscore = _comscore || [];
      _comscore.push({ c1: "2", c2: "8428430" });
      (function() {
        var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
        s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
        el.parentNode.insertBefore(s, el);
      })();
    </script>    
    <!-- End comScore Tag -->
    <noscript>
        <img src="http://b.scorecardresearch.com/p?c1=2&c2=8428430&cv=2.0&cj=1" alt="" />
    </noscript>

    <script type="text/javascript">
    ....
    <body>
    ....