简体   繁体   English

下载文件时关闭jquery iframe

[英]close jquery iframe when file downloaded

I use the following ajax to open a url that make and download xls and pdf reports. 我使用以下ajax打开制作并下载xls和pdf报告的网址。 This open a iframe in jquery dialog. 这样会在jquery对话框中打开iframe When the dialog open the user will must wait to download the file. 对话框打开时,用户必须等待下载文件。 When the file downloaded I want to close the dialog. 下载文件后,我想关闭对话框。

I tried the following but is not work any idea? 我尝试了以下方法,但是行不通?

$.ajax({
    type: 'POST',
    url: '../menu/solonreport.jsp',
    data: {
        Wreportid: reportid,
        Wreporttype: reporttype
    },
    async: false,
    dataType: 'json',
    success: function(json) {
        var ifr = $('<iframe/>', {
            id: 'iframereport',
            src: json.url,
            style: 'display:none',
            load: function() {
                $("#dialog-report").dialog("close");
            }
          }
        });

        $("#dialog-report").append(ifr).dialog();    
});

following the html: 跟随html:

<div id="dialog-report" title="Eκτύπωση" style="display: none;">
    <span class="ui-icon ui-icon-info" style="float:left; margin:0 7px 50px 0;"></span>
    Please wait...
    <iframe id="iframereport" src=""  width="0" height="0"></iframe>
</div>

There is a syntax error in the code you copied. 您复制的代码中存在语法错误。 You are missing a closing bracket for your success callback 您缺少成功回调的结尾

        $("#dialog-report").append(ifr).dialog();  
     } //This one is missing
 })

I hope that your problem is only that 我希望你的问题仅仅是

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

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