关闭弹出窗口并打开新弹出窗口

时间:2013-03-09 06:08:13

标签: javascript jquery

我正在使用模态弹出窗口。当我点击关闭时,我想关闭当前弹出窗口n想要打开一个新的弹出窗口..这可能吗?我在javascript以下使用..

请帮帮我..

$(document).ready(function() {  

    //select all the a tag with name equal to modal
    $('a[name=modal]').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();

        //Get the A tag
        var id = $(this).attr('href');

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});

        //transition effect     
        $('#mask').fadeIn(1000);    
        $('#mask').fadeTo("slow");  

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        $(id).css('top',  winH/8-$(id).height()/8);
        $(id).css('left', winW/2-$(id).width()/2);

        //transition effect
        $(id).fadeIn(2000);

    });  

    //if close button is clicked
    $('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        $('#mask').fadeOut(1000);
        $('.window').fadeOut();
    }); 


    //if mask is clicked
    //$('#mask').click(function () {
        //$(this).fadeOut(1000);
        //$('.window').fadeOut();
     // });         

    $(window).resize(function () {

        var box = $('#boxes .window');

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set height and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});

        //Get the window height and width
      var winH = $(window).height();
          var winW = $(window).width();

        //Set the popup window to center
        box.css('top',  winH/8 - box.height()/8);
        box.css('left', winW/2 - box.width()/2);

    });

});

0 个答案:

没有答案