Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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
Jquery 在一定的秒数后自动关闭模式框_Jquery_Joomla_Popup_Modal Dialog - Fatal编程技术网

Jquery 在一定的秒数后自动关闭模式框

Jquery 在一定的秒数后自动关闭模式框,jquery,joomla,popup,modal-dialog,Jquery,Joomla,Popup,Modal Dialog,嘿,伙计们,我在这里搜索过,但找不到关于这个的答案 我有一个JoOMLA站点,想在页面加载时使用一个模态框在站点的中间显示一个横幅。到目前为止还不错,我使用了我在这里找到的脚本:一切都像一个符咒 我的问题是,当我添加自己的代码时,会自动关闭模式框。这段代码可以工作,但是用户不能自己关闭模式。你能告诉我怎么做吗?这样它就可以正常工作了(可以自动关闭,但也可以由用户关闭) 我的代码带有注释//延迟后淡出 代码: 这是: 尝试使用setTimeout()而不是delay()你试过使用setTimeou

嘿,伙计们,我在这里搜索过,但找不到关于这个的答案

<>我有一个JoOMLA站点,想在页面加载时使用一个模态框在站点的中间显示一个横幅。到目前为止还不错,我使用了我在这里找到的脚本:一切都像一个符咒

我的问题是,当我添加自己的代码时,会自动关闭模式框。这段代码可以工作,但是用户不能自己关闭模式。你能告诉我怎么做吗?这样它就可以正常工作了(可以自动关闭,但也可以由用户关闭)

我的代码带有注释//延迟后淡出

代码:

这是:


尝试使用
setTimeout()
而不是
delay()

你试过使用
setTimeout()
吗?哇,真是妙招!非常感谢你!!!没问题,我是否应该发布答案如果你能从中获得分数,那就一定要努力!我会记下它的答案:)
var popupStatus = 0;
var $j = jQuery.noConflict();
//this code will load popup with jQuery magic!
function loadPopup(){
    //loads popup only if it is disabled
    if(popupStatus==0){
        $j("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $j("#backgroundPopup").fadeIn("slow");
        $j("#popupContact").fadeIn("slow");
        popupStatus = 1;
    }
}

//This code will disable popup when click on x!
function disablePopup(){
    //disables popup only if it is enabled
    if(popupStatus==1){
        $j("#backgroundPopup").fadeOut("slow");
        $j("#popupContact").fadeOut("slow");
        popupStatus = 0;
    }
}   
//this code will center popup
function centerPopup(){
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $j("#popupContact").height();
    var popupWidth = $j("#popupContact").width();
    //centering
    $j("#popupContact").css({
        "position": "absolute",
        "top": windowHeight/2-popupHeight/2,
        "left": windowWidth/2-popupWidth/2
    });
    //only need force for IE6   
    $j("#backgroundPopup").css({
        "height": windowHeight
    });

}
//CONTROLLING EVENTS IN jQuery
$j(document).ready(function(){
    if ($j.cookie("anewsletter") != 1) {   
        //centering with css
        centerPopup();
        //load popup
        loadPopup();
        $j.cookie("anewsletter", "1", { expires: 1 });
    }
    //CLOSING POPUP
    //Click the x event!
    $j("#popupContactClose").click(function(){
        disablePopup();
    });
    //Click out event!
    $j("#backgroundPopup").click(function(){
        disablePopup();
    });
    //Press Escape event!
    $j(document).keypress(function(e){
        if(e.keyCode==27 && popupStatus==1){
            disablePopup();
        }
    });
    //fade out after delay
    $j("#backgroundPopup").delay(15000).fadeOut("slow");
    $j("#popupContact").delay(15000).fadeOut("slow");
});