Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在退出时调用另一个模式覆盖_Javascript_Jquery_Modal Dialog_Overlay - Fatal编程技术网

Javascript 如何在退出时调用另一个模式覆盖

Javascript 如何在退出时调用另一个模式覆盖,javascript,jquery,modal-dialog,overlay,Javascript,Jquery,Modal Dialog,Overlay,我正在使用这个脚本加载我在我的站点上创建的一些覆盖模型。模态是通过以下方式触发的: <a class="activate_modal" name="modal_window" href="#">call it now!</a> 当用户试图关闭/退出页面时,是否要调用事件?@Suman Bogati我想调整函数show_modal以在退出时显示模式窗口3。您不能。出于安全原因,从页面导航时,浏览器只接受一个字符串,这是您希望在本机窗口(如JSconfirm())中向用户

我正在使用这个脚本加载我在我的站点上创建的一些覆盖模型。模态是通过以下方式触发的:

<a class="activate_modal" name="modal_window" href="#">call it now!</a> 

当用户试图关闭/退出页面时,是否要调用事件?@Suman Bogati我想调整函数show_modal以在退出时显示模式窗口3。您不能。出于安全原因,从页面导航时,浏览器只接受一个字符串,这是您希望在本机窗口(如JS
confirm()
)中向用户询问的问题。
$(document).ready(function(){
//get the height and width of the page
var window_width = $(window).width();
var window_height = $(window).height();
//vertical and horizontal centering of modal window(s)
/*we will use each function so if we have more then 1 
modal window we center them all*/
$('.modal_window').each(function(){
    //get the height and width of the modal
    var modal_height = $(this).outerHeight();
    var modal_width = $(this).outerWidth();
    //calculate top and left offset needed for centering
    var top = (window_height-modal_height)/3;
    var left = (window_width-modal_width)/3;
    //apply new top and left css values 
    $(this).css({'top' : top , 'left' : left});
});
    $('.activate_modal').click(function(){
          //get the id of the modal window stored in the name of the activating element       
          var modal_id = $(this).attr('name');
          //use the function to show it
          show_modal(modal_id);
    });
    $('.close_modal').click(function(){
        //use the function to close it
        close_modal();
    });
});
//THE FUNCTIONS
function close_modal(){
    //hide the mask
    $('#mask').fadeOut(500);
    //hide modal window(s)
    $('.modal_window').fadeOut(500);
}
function show_modal(modal_id){
    //set display to block and opacity to 0 so we can use fadeTo
    $('#mask').css({ 'display' : 'block', opacity : 0});
    //fade in the mask to opacity 0.8 
    $('#mask').fadeTo(500,0.8);
     //show the modal window
    $('#'+modal_id).fadeIn(500);
}