当有人使用Facebook登录时隐藏文本框

问题描述:

当有人点击我网站上的Facebook登录按钮时,您是否知道如何在我的代码中隐藏文本框和按钮?我使用此代码让我的用户能够使用facebook登录。



Do you know how to hide textboxes and a button in my code when someone clicks the facebook Log In button on my web site. I use this code for my users to be able to login with facebook.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"  Inherits="_Default" %>
      <!DOCTYPE html>
     &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
     &lt;head runat="server">
    &lt;title>&lt;/title>
    <%--&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">&lt;/script>--%>
    &lt;script src="//connect.facebook.net/en_US/all.js">&lt;/script>
    &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">&lt;/script>
    <script type="text/javascript" src="jquery.maphilight.min.js">&lt;/script>
    </head>
    <body style="background-color:azure">
    &lt;script type="text/javascript">
        (function (d) {
            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.js";
            ref.parentNode.insertBefore(js, ref);
        }(document));

        // Init the SDK upon load
        window.fbAsyncInit = function () {
            FB.init({
                appId: '487818951287950', // App ID
                channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });

            // listen for and handle auth.statusChange events
            FB.Event.subscribe('auth.statusChange', function (response) {
                if (response.authResponse) {
                    // user has auth'd your app and is logged into Facebook
                    FB.api('/me', function (me) {
                        if (me.name) {
                     document.getElementById('auth-displayname').innerHTML = me.name;
                        }
                    })
       document.getElementById('auth-loggedout').style.display = 'none';
       document.getElementById('auth-loggedin').style.display = 'block';
                } else {
                    // user has not auth'd your app, or is not logged into Facebook
       document.getElementById('auth-loggedout').style.display = 'block';
        document.getElementById('auth-loggedin').style.display = 'none';
                }
            });
            $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); });
        }
    &lt;/script>
    &lt;form id="form1" runat="server">

        <div class="fb-login-button" id="fbkopce" runat="server">
       <div id="auth-status" >
     <div id="auth-loggedout" >

      <fb:login-button class="fb-login-button" autologoutlink="true"     scope="email,user_checkins">Најави се Facebook</fb:login-button>
      </div>
      <div id="auth-loggedin" style="display: none">
       Добредојде, <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">одјави    се</a>)
       </div>
      </div>
      </div>

                <asp:TextBox ID="TextBox3" runat="server" Height="22px">username</asp:TextBox>   <br/>

                <asp:TextBox ID="TextBox4" runat="server" TextMode="Password"  ToolTip="Password">password</asp:TextBox><br />



        <asp:Button ID="Button1" runat="server" Text="Најави се!" OnClick="Button1_Click" />

        &lt;/form>


       &lt;/body>
      &lt;/html>

#auth-logoutlink)。click( function (){FB.logout( function (){ window location .reload(); });});
}
& lt; / script>
& lt; form id = form1 runat = server>

< div class = fb-login-button id = fbkopce runat = server>
< div id = auth-status>
< div id = auth-loggedout>

< fb:login-button class = fb-login-button autologoutlink = true范围= email,user_checkins>НајависеFacebook&lt ; / fb:login-button >
< / div >
< div id = auth-loggedin style = display:none> $ b $bДобредојде,< span id = auth-displayname> < / span > (< a href = id = auth-logoutlink>одјависе< / a >
< / div >
< / div >
< / div >

< asp:T extBox ID = TextBox3 runat = server高度= 22px >用户名< / asp:TextBox > < br />

< asp:TextBox ID = TextBox4 runat = server TextMode = 密码 ToolTip = 密码>密码< / asp:TextBox > < br />



< asp:按钮ID = Button1 runat = server Text = Најависе! OnClick = Button1_Click />

& lt; / form>


& lt; / body>
& lt; / html>
("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); }); } &lt;/script> &lt;form id="form1" runat="server"> <div class="fb-login-button" id="fbkopce" runat="server"> <div id="auth-status" > <div id="auth-loggedout" > <fb:login-button class="fb-login-button" autologoutlink="true" scope="email,user_checkins">Најави се Facebook</fb:login-button> </div> <div id="auth-loggedin" style="display: none"> Добредојде, <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">одјави се</a>) </div> </div> </div> <asp:TextBox ID="TextBox3" runat="server" Height="22px">username</asp:TextBox> <br/> <asp:TextBox ID="TextBox4" runat="server" TextMode="Password" ToolTip="Password">password</asp:TextBox><br /> <asp:Button ID="Button1" runat="server" Text="Најави се!" OnClick="Button1_Click" /> &lt;/form> &lt;/body> &lt;/html>


...或者,您可以使用CSS可见性属性,以及相应的 style.visibility 您可以在JavaScript中修改的DOM元素属性: http://www.w3schools.com /cssref/pr_class_visibility.asp [ ^ ] 。



-SA
…Alternatively, you can use CSS visibility property, as well as the corresponding style.visibility DOM element property you could modify in JavaScript: http://www.w3schools.com/cssref/pr_class_visibility.asp[^].

—SA