HREF属性包含fb注释,ajax load(pushState)和定义href属性

时间:2013-04-03 12:04:33

标签: ajax facebook comments

我真的很喜欢这个,所以我希望任何人都可以看看和帮助。

我使用pushState和fb注释构建ajax-ed网页。问题是,每当我加载新内容和fb注释时,我都会收到有关设置href属性的错误。 这是代码:

首先,我异步调用fb init:

<script>
window.fbAsyncInit = function() {
FB.init({
appId      : 'MY_APP_ID', 
channelUrl : 'http://promplac.si/channel.php', 
status     : true, 
cookie     : true, 
xfbml      : true  
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js';document.getElementById('fb-root').appendChild(e);
}());
</script>

关于内容更改,我致电:

<script>      
function showComment($currentUrl) {
document.getElementById('theplace').innerHTML='<fb:comments id="fbcomment" href="'+document.URL+'" width="510" num_posts="3"></fb:comments>';
console.log(document.getElementById('theplace').innerHTML);
FB.XFBML.parse();
console.log(document.getElementById('theplace').innerHTML);
    }
</script>

HTML:

<div id="theplace" class="fb-comments"><fb:comments href="" numposts='3' height='150' id="fbcomment"  width="510" num_posts="3"></fb:comments></div>

我做了一个例子,在FB.XFBML.parse()调用之前和之后,我在console.log中输入了html的注释。正如您在此示例中看到的那样:http://promplac.si/nagradne-igre/nagradna-igra/izberi-oblacila-v-vrednosti-200EUR/

评论是正常显示的,但是当您点击任何其他条目时,我会收到有关设置href属性的警告。但是,如果你检查控制台,href属性完全可以吗?当至少有一条评论时,效果不会发生......

知道出了什么问题吗?

0 个答案:

没有答案
相关问题