阻止UI无法正常工作

时间:2013-04-10 09:04:44

标签: javascript asp.net web blockui

为什么这段代码不起作用? 我在将文件下载到fileDownloadToken时设置了cookie。并检查它是否为null然后exec finishdownload ...

   <script type="text/javascript">
    var fileDownloadCheckTimer;
    function blockUIForDownload() {
        if (IsCookiesEnable()) {
            var token = new Date().getTime(); //use the current timestamp as the token value
            $('#token').val(token);
            $.blockUI{ message: '', fadeIn: 0 };);
            fileDownloadCheckTimer = window.setInterval(function () {
                var cookieValue = $.cookie('fileDownloadToken');
               // alert(cookieValue);
                if (cookieValue != null)
                    finishDownload();
            }, 1000);
        }
    }

    function IsCookiesEnable() {
        var cookieEnabled = (navigator.cookieEnabled) ? true : false;

        if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
            document.cookie = "testcookie";
            cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
        }
        return (cookieEnabled);
    }

    function finishDownload() {
        //window.clearInterval(fileDownloadCheckTimer);
        $.cookie('fileDownloadToken', null);
        $.unblockUI();
    }

1 个答案:

答案 0 :(得分:2)

更改

$.blockUI{ message: '', fadeIn: 0 };);

$.blockUI({ message: '', fadeIn: 0});