0

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)&amp;width=190&amp;height=290&amp;show_faces=true&amp;colorscheme=light&amp;stream=false&amp;show_border=true&amp;header=false&amp;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));

4

1 に答える 1

0

試す

iframe に iframe1 という名前を付けました

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">


 <iframe id="iframe1" src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2F(page name)&amp;width=190&amp;height=290&amp;show_faces=true&amp;colorscheme=light&amp;stream=false&amp;show_border=true&amp;header=false&amp;appId=150863001672601" scrolling="no" frameborder="0" style="padding:10px; border:1px solid #000000; background:#e1e1e1; overflow:hidden; width:160px; height:290px;" allowTransparency="true"></iframe>

     <input type="button" id="btn" onclick="btnclk()" />


    </form>
</body>
</html>
<script type="text/javascript">

    function btnclk() {
        var ifr = document.getElementById("iframe1");
        ifr.style.display = "none";
    }
</script>
于 2013-07-16T09:57:15.713 に答える