「送信」/「いいね」ボタンに典型的な問題があります。私のページには、ajax リクエストを使用して動的に更新されるコンテンツが含まれています。そのため、更新後、「送信ボタン」が機能しませんでした。ボタンのコード:
<div class="fb-send" data-href="${server}/book.html?currBookId=${book.id_book}"
style="margin-top: 5px;"></div>
all.js ファイルを含む標準コード:
<script type="text/javascript">(function(d, s, id) {
if (d.getElementById(id)) return;
var js, fjs = d.getElementsByTagName(s)[0];
js = d.createElement(s);
js.id = id;
var lang = "${lang}";
js.src = "//connect.facebook.net/en_US/all.js'#xfbml=1&appId=${fb_id}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
ここで答えを見つけようとしましたが、解決策が見つかりました: stackoverflowソリューションの投稿
これを追加する必要があります:
try{
FB.XFBML.parse();
} catch(ex) {}
AJAX 呼び出しの後。しかし!!うまくいきません!ボタンは現在 Chrome ブラウザーで描画されていますが、コンソールでは次のような多くのエラーが発生しています。
Unsafe JavaScript attempt to access frame with URL http://localhost:8080/catalog.html
from frame with URL http://www.facebook.com/plugins/send.php?api_key=API-
KEY&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion
%3D9%23cb%3Df847c7b0c%26origin%3Dhttp%253A%252F%252Flocalhost%253A8080%252Ff8c34834
c%26domain%3Dlocalhost%26relation%3Dparent.parent&colorscheme=light&
extended_social_context=false&href=http%3A%2F%2FMySite.com
%2Fbook.html%3FcurrBookId%3D2668&locale=ru_RU&sdk=joey.
Domains, protocols and ports must match.
そしてボタンが効かない。FF ではボタンが表示されません (これは、ソリューションが FF で機能していないことを意味します)
この問題を解決する方法はありますか?