繁体   English   中英

我如何在加载时打开此模式窗口-PHP

[英]How do I get this modal window to open on load - PHP

我从以下链接下载了登录模式。 http://www.alessioatzeni.com/blog/login-box-modal-dialog-window-with-css-and-jquery/

我对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,因此为什么下载了该插件。 我真的需要这个工作。

我已经尝试与编写此代码的人联系,但他从未答复。

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

只需添加该行,即可在页面加载时执行click事件。

您的代码正在等待用户在加载模式之前单击登录按钮。 尝试这个:

$(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(){})中的所有内容; 页面加载完成后将立即触发。

$('a.loginbutton')。click(function(){})中的所有内容; 仅当用户单击该按钮时才会触发。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM