繁体   English   中英

jQuery函数未在条件循环中触发

[英]jQuery function not triggering in a conditional loop

scanStatus == 'limit'centerPopup()loadPopup()函数不会触发。

这些函数是从名为js/count.js的文件中调用的。 该文件位于此处

这些是我的函数,存储在js/popup.js

// Loading popup with jQuery magic!
function loadPopup() {
    // Loads popup only if it is disabled
    if (popupStatus == 0) {
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });

        $("#backgroundPopup").fadeIn("slow");
        $("#popupContact").fadeIn("slow");

        popupStatus = 1;
    }
}

// Centering popup
function centerPopup() {
    // Request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#popupContact").height();
    var popupWidth = $("#popupContact").width();

    // Centering
    $("#popupContact").css({
        "position": "absolute",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });

    // Only need force for IE6
    $("#backgroundPopup").css({
        "height": windowHeight
    });
}

这两个文件都包含在HTML中,如下所示:

<script type="text/javascript">
    var uid = "rZCENk6w";
    var website = "http://www.engadget.com";
</script>

<script type="text/javascript" src="js/popup.js"></script>
<script type="text/javascript" src="js/count.js"></script>

预先感谢您的任何帮助。

根据在链接文件中(位于底部附近)中找到的代码,永远不会在准备就绪的文档上调用这些方法,因为它们已被注释掉:

//if (scanStatus == 'limit') {
    //LOADING POPUP
    //Click the button event!
    //$("#button").click(function(){
        //centering with css
        //centerPopup();
        //load popup
        //loadPopup();
//});}

您需要取消注释它们以便相应地执行它们:

if (scanStatus == 'limit') {
    $("#button").click(function() {
        centerPopup();
        loadPopup();
    });
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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