2013-02-06 80 views
0

我從下面的鏈接下載了登錄模式。 http://www.alessioatzeni.com/blog/login-box-modal-dialog-window-with-css-and-jquery/我如何獲得這個模式窗口打開負載 - PHP

我對CSS做了一些更改,但就是這樣。

這裏是jQuery的代碼,啓動模式窗口,當我按一下按鈕..

$(document).ready(function() { 
$('a.loginbutton').click(function() { 

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

    //Fade in the Popup and add close button 
    $(loginBox).fadeIn(300); 
    $.fn.formLabels(); //Initialize form labels 

    //Set the center alignment padding + border 
    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; 
}); 
    }); 

基本上,我需要這個模式在網頁加載加載。我幾乎不瞭解jQuery,因此我下載了插件。我真的需要這個工作。

我已經試着聯繫編寫此代碼的人,但他從未回覆過。

回答

4
$('a.loginbutton').click(); 

只需添加該行,即可在頁面加載時執行單擊事件。

-1

您的代碼正在等待用戶在加載模態之前單擊登錄按鈕。試試這個:

$(document).ready(function() { 
//$('a.loginbutton').click(function() { 

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

//Fade in the Popup and add close button 
$(loginBox).fadeIn(300); 
$.fn.formLabels(); //Initialize form labels 

//Set the center alignment padding + border 
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; 
//}); 
}); 

我想我已經註釋掉了.click()函數。

$(document).ready(function(){});一旦頁面加載完成,將立即觸發 。點擊(功能(){});點擊(功能(){})。只會在用戶點擊該按鈕時觸發。