facebook分享用php和javascript生成白色/空白页面

时间:2014-01-04 05:14:21

标签: javascript php html facebook

好吧基本上我正在尝试使用facebook分享按钮获取白页,包括new和sharer.php版本

我正在尝试分享以下网址: https://www.facebook.com/sharer/sharer.php?u=https:// * *。com / 3e68ec7f58134f66d09a1c05c2783385 / index.html中

现在,如果我粘贴在新的浏览器窗口中,或者甚至当我刷新白/黑页时页面加载正常

这是我的代码:

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
    overflow:hidden;
}
</style>
<link rel="stylesheet" href="onlinedojo/css/layout.css" type="text/css" media="screen" />
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="onlinedojo/js/hideshow.js" type="text/javascript"></script>
<script src="onlinedojo/js/jquery.tablesorter.min.js" type="text/javascript">    </script>
<script type="text/javascript" src="onlinedojo/js/jquery.equalHeight.js"></script>
<title>post</title>
</head>
<body>
<div id="fb-root"></div>
<script>
function postToFb(){
window.open('<?php echo $fburl ?>','1317220786706','width=400,height=400,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
    window.close();
    return false;
}
</script>
<form class="submit_link" style="float:right">
                &nbsp;<input type="submit" class="alt_btn"     value="Share on Facebook" onclick="postToFb();" />
            </form>
</body>
</html>

任何帮助都会受到赞赏 - 这让我发疯了!

2 个答案:

答案 0 :(得分:0)

好吧,你试试这个

<script>
    function postToFb(url) {
        window.open(url, '_blank', 'width=530,height=460,left=' + (screen.availWidth / 2 - 250) + ',top=' + (screen.availHeight / 2 - 250) + '');
        return false;
    }

<?php 
    $title = urlencode('your title');
    $summary = urlencode('your sumary');
    $url_base = urlencode('url to share');
    $url_image = urlencode('thumbnail url');
    $url_to_share = "http://www.facebook.com/sharer/sharer.php?s=100&p[title]=$title&p[summary]=$summary&p[url]=$url_base&p[images][0]=$url_image";
?>

postToFb('<?php echo urlencode($url_to_share) ?>') {

</script>

我希望这对你有所帮助。

答案 1 :(得分:0)

此处您不需要表单或提交按钮。所以只需删除表单和按钮并放置简单的共享链接并尝试此

<强> HTML:

<a href="javascript: void(0)" onClick="fbpopup('<?php echo urlencode($fburl); ?>')">
 Share on Facebook
</a>

<强>的Javascript

<script>
function fbpopup(popwhat) {
window.open( popwhat, "fbshare", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" )
} 
</script>