2013-02-12 8 views
12

FB共有者ポップアップウィンドウには、私がPHPリンクに挿入したメタデータではなく、ページのデータが表示されます。facebook Sharerポップアップウィンドウ

<a href="http://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=Google&p%5Burl%5D=http%3A%2F%2Fwww.google.com&p%5Bsummary%5D=Google search engine&p%5Bimages%5D%5B0%5D=https://www.google.com/images/srpr/logo3w.png 
"onClick="return fbs_click(626, 305)" target="_blank" title="Share">FACEBOOK</a> 

私がポップアップウィンドウに正しいデータを表示することができますどのようにJavaScriptの

<script type="text/javascript"> 
function fbs_click(width, height) { 
var leftPosition, topPosition; 
leftPosition = (window.screen.width/2) - ((width/2) + 10); 
topPosition = (window.screen.height/2) - ((height/2) + 50); 
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=no,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"; 
u=location.href; 
t=document.title; 
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures); 
return false; 
} 
</script> 

によって引き起こされているように見えますか?

答えて

49

カスタムメタデータを追加したい場合は、使用後のコード:

<a id="fb-share" style='text-decoration:none;' type="icon_link" onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]=YOUR_DESCRIPTION&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE','sharer','toolbar=0,status=0,width=580,height=325');" href="javascript: void(0)">Share</a> 

UPDATE:

私はFacebookで共有のために少しJSコードを書きました。

Javascriptを:

function fbShare(url, title, descr, image, winWidth, winHeight) { 
     var winTop = (screen.height/2) - (winHeight/2); 
     var winLeft = (screen.width/2) - (winWidth/2); 
     window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width='+winWidth+',height='+winHeight); 
    } 

HTML:

<a href="javascript:fbShare('http://jsfiddle.net/stichoza/EYxTJ/', 'Fb Share', 'Facebook share popup', 'http://goo.gl/dS52U', 520, 350)">Share</a> 
+0

完璧、ありがとう:)私は、上部の角の代わりにページの真ん中にポップアップを持つことができた場合、今すぐ。 – no0ne

+0

@ThomasBLundは私の編集された答えをチェックアウト、すべて正常に動作します:) – Stichoza

+0

これは継続ソリューション)を「いくつかの共有ボタンのog-metaタグ」についての私の他の質問に - http://stackoverflow.com/questions/14818698/open-graph-meta-tags-for-several-share-buttons - ありがとうStichoza – no0ne

関連する問題