0

ダウンロードが完了するまでページをブロックしてから、ブロックを解除したい。私はこのコードを書きますが、1 秒後に UI のブロックを解除し、ダウンロードはまだ完了していません。

   <script type="text/javascript">
    var fileDownloadCheckTimer;
    function blockUIForDownload() {
        if (IsCookiesEnable()) {
            var token = new Date().getTime(); //use the current timestamp as the token value
             $.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();

    }


asp.net、C#、blockUi プラグインを使用しています。

4

0 に答える 0