当弹出窗口打开时,我在jquery ready函数上创建了一个脚本,如果我单击body标签,它会关闭弹出窗口。我蚂蚁,如果点击弹出部分以外的身体不要关闭弹出。我尝试了很多方法但是没有用。弹出就绪函数而不是点击事件。所以没有点击打开弹出窗口。当访问者打开网站时它会打开。成功登录后关闭。所以如果访问者没有登录弹出应该没有关闭。 HTML
{% form 'customer_login' %}
<header class="page-header">
<h1>Customer Login</h1>
</header>
{% include 'form-errors-custom' %}
<label for="customer_email">Email Address<em>*</em></label>
<input type="email" value="" name="customer[email]" id="customer_email"
{% if form.errors contains "email" %} class="error"{% endif %} >
{% if form.password_needed %}
<label for="customer_password">Password<em>*</em></label>
<input type="password" value="" name="customer[password]" id="customer_password" {% if form.errors contains "password" %} class="error"{% endif %}>
{% endif %}
<div class="action-btn">
<p><input type="submit" class="btn" value="Login"></p>
<p class="last">
<a href="#" onclick="showRecoverPasswordForm();return false;" class="forgetpass">Forgot your password?</a>
<span>or</span> <a href="javascript:void(0)" class="register-form"> Register</a>
</p>
</div>
{% endform %}
JS
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function() { //
var newletter = jQuery(".newsletterwrapper").html();
jQuery("body").after(newletter);
var loggedin = jQuery(".userlogged").text();
var login = jQuery(".usernotlogged").text();
if(loggedin !=""){
closeEmailModalWindow();
}
if(login !=""){
openEmailModalWindow();
}
jQuery('#email-modal .btn.close').click(function(e) {
e.preventDefault();
closeEmailModalWindow();
});
jQuery('body').keydown(function(e) {
if( e.which == 27) {
//closeEmailModalWindow();
jQuery('body').unbind('keydown');
}
});
function closeEmailModalWindow (e) {
jQuery('#email-modal .modal-window').fadeOut(600, function() {
jQuery('#email-modal .modal-overlay').fadeOut(600, function() {
jQuery('#email-modal').hide();
//jQuery.cookie('emailSubcribeModal', 'closed', {expires:1, path:'/'});
});
})
}
function openEmailModalWindow () {
jQuery('#email-modal').fadeIn(600, function(e) {
jQuery('#email-modal .modal-window').fadeIn(600);
jQuery('.newsletterwrapper').remove();
jQuery('#email-modal').css('display','block');
jQuery("body").attr('disabled',true);
});
}
});