0

ボタンクリックで呼び出すことができる次のjqueryログインフォームがありますが、phpログインチェックがfalseの場合にも呼び出されるようにします。PHPで呼び出せるようにするには、何を追加できますか?

  <script type="text/javascript">

             $(document).ready(function() {
$('a.login-window, a.log').click(function() {

            //Getting the variable's value from a link 
    var loginBox = $(this).attr('href');

    //Fade in the Popup
    $(loginBox).fadeIn(300);

    //Set the center alignment padding + border see css style
    var popMargTop = ($(loginBox).height() + 24) / 2; 
    var popMargLeft = ($(loginBox).width() + 24) / 2; 

    $(loginBox).css({ 
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    // Add the mask to body
    $('body').append('<div id="mask"></div>');
    $('#mask').fadeIn(300);

    return false;
});

// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() { 
  $('#mask , .login-popup').fadeOut(300 , function() {
    $('#mask').remove();  
}); 
return false;
});
});
             </script>
4

1 に答える 1

0

ログイン リクエストが無効な場合にログイン フォームを開く呼び出しをセットアップします。

$(document).ready(function () {
    $('a.login-window, a.log').click(function () {
        //Getting the variable's value from a link 
        var loginBox = $(this).attr('href');

        //Fade in the Popup
        $(loginBox).fadeIn(300);

        //Set the center alignment padding + border see css style
        var popMargTop = ($(loginBox).height() + 24) / 2;
        var popMargLeft = ($(loginBox).width() + 24) / 2;

        $(loginBox).css({
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft
        });

        // Add the mask to body
        $('body').append('<div id="mask"></div>');
        $('#mask').fadeIn(300);

        return false;
    });

    // When clicking on the button close or the mask layer the popup closed
    $('a.close, #mask').live('click', function () {
        $('#mask , .login-popup').fadeOut(300, function () {
            $('#mask').remove();
        });
        return false;
    });
});

次に、少なくとも前回の実行 (セットアップではなく、handler を実行) ののどこかで、次のようにします。$.ready()

if ($php_login_request === true && $php_user_authenticated !== true) { 
    echo "<script>$('a.login-window, a.log').trigger('click');</script>";
}

これらの変数にマークを付けた$php_ので、サーバー上で実行する必要があることがわかります。明らかに、認証ステップと `' タグの終わりの間のある時点です。

于 2013-03-23T21:28:15.480 に答える