Facebook 共享脚本不起作用

Facebook sharing script not working

我正在使用此脚本进行分享 options.This 在 single.php 上运行良好。 问题出在主页上,我有 10 posts..每个 post 都有一个共享按钮。 但是当用户点击任何 post 进行分享时,只有循环中的最后一个 post 被分享

    <script>
function facebook()
{
window.open("http://facebook.com/sharer.php?app_id=1433580610197489&sdk=joey&u=<?php the_permalink(); ?>","_blank","toolbar=no, scrollbars=no, resizable=yes, top=500, left=500, width=650, height=540");
}

function google()
{
window.open("https://plus.google.com/share?url=<?php the_permalink(); ?>","_blank","toolbar=no, scrollbars=no, resizable=yes, top=500, left=500, width=650, height=540");
}
function twitter()
{
window.open("http://twitter.com/home?status=<?php the_permalink(); ?>","_blank","toolbar=no, scrollbars=no, resizable=yes, top=500, left=500, width=650, height=540");
}

</script> 

                              <a title="Facebook" onclick="facebook()" ><i class="fa fa-facebook"></i></a>
                              <a title="Twitter" onclick="twitter()" ><i class="fa fa-twitter"></i></a>
                              <a title="Google+" onclick="google()" ><i class="fa fa-google-plus"></i></a> 

我理解的对吗,你有这样的东西:

for (var i=0; i < 10; i++) {
function facebook() { ... }
[...]
<a title="Facebook" onclick="facebook()" ><i class="fa fa-facebook"></i></a>                    
}

如果是这样,您每次都会覆盖 facebook() 函数。

尝试这样的事情:

function facebook(permalink) {
window.open("http://facebook.com/sharer.php?app_id=1433580610197489&sdk=joey&u=" + permalink,"_blank","toolbar=no, scrollbars=no, resizable=yes, top=500, left=500, width=650, height=540");
}

<a title="Facebook" onclick="facebook('<?php the_permalink(); ?>')" ><i class="fa fa-facebook"></i></a>