延迟弹出60秒

时间:2015-10-18 18:44:53

标签: javascript jquery delay popover

我正在使用以下脚本在我的客户端页面上显示一个弹出窗口。她要求延迟60秒。我正在使用#mask,但我无法实现它。它推迟#boxes #dialog,但不推迟$(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(); }); });

您可以在此处查看该网站:http://www.julialucille.com/

任何帮助将不胜感激,谢谢! 这是我的剧本。

<%@ taglib prefix="c" 
           uri="http://java.sun.com/jsp/jstl/core" %>

1 个答案:

答案 0 :(得分:0)

确保CSS中的#mask#dialog都设置为display: none;,然后根据以下脚本使用setTimeout

$(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();
  });

});