简体   繁体   中英

Delay popup 60 seconds

I am using the following script to bring up a popover on my client's page. She has requested that it be delayed 60seconds. I am using setTimeout , but I'm having trouble implementing it. It is delaying #mask , but not #boxes #dialog

You can view the site here: http://www.julialucille.com/

Any help would be appreciated, thank you! Here is my script.

$(document).ready(function() {  

    setTimeout(function(){
        var id = '#dialog';

        //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});

        //transition effect     

        $('#mask').fadeTo("slow",0.3); 
        $('#boxes #dialog').fadeTo("slow"); 

    }, 60000);

    //if close button is clicked
    $('.window .close').click(function (e) {

        //Cancel the link behavior
        e.preventDefault();
        $('#mask').hide();
        $('.window').hide();
    });

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

});

Make sure both #mask and #dialog are both set to display: none; in the CSS, then use setTimeout according to the following script

 $(document).ready(function() { setTimeout(function(){ var id = '#dialog'; //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').fadeTo("slow",0.3); $(id).fadeTo("slow", 1); }, 30000); //if close button is clicked $('.window .close').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask').hide(); $('.window').hide(); }); //if mask is clicked $('#mask').click(function () { $(this).hide(); $('.window').hide(); }); }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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