Facebook のようなボックスを Web サイトに追加しました。これはギャンブル サイトであるため、年齢を確認してコンテンツを表示できるようにログインする必要があります..これは問題ありません。
私の問題は、ユーザーが Facebook にログインしていない場合でも、コンテンツがなくても [いいね!] ボックスが表示され、背景色が空であることです。
javascript を使用して iframe の周囲に含まれる div を display:none に非表示にする方法はありますか?
<iframe src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2F(page name)&width=190&height=290&show_faces=true&colorscheme=light&stream=false&show_border=true&header=false&appId=150863001672601" scrolling="no" frameborder="0" style="padding:10px; border:1px solid #000000; background:#e1e1e1; overflow:hidden; width:160px; height:290px;" allowTransparency="true"></iframe>
私はこれを思いつきましたが、これが正しい方向にあるかどうかはわかりません:
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '{app_id}', // App ID from the App Dashboard
channelUrl : '//path/to/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
FB.getLoginStatus(function (response) {
if ((response.status === 'connected') || (response.status === 'not_authorized')) {
$('#facepileDiv').show();
}
});
};
// Load the SDK's source Asynchronously
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));