【问题标题】:How to show download as prompt on new window from bootstrap model?如何从引导模式在新窗口上显示下载提示?
【发布时间】:2018-08-24 10:43:58
【问题描述】:

对于普通的 HTML 页面,我尝试了以下代码,该代码在单独的窗口中开始下载。当我对引导模式形式使用相同的代码时,它就不起作用了。为了在引导模式中实现相同的功能,我还需要做什么?

 var newwin=window.open("",'newwindow','width=700,height=700, left=100,top=100,resizable=yes','_blank').document;
    var link =newwin.createElement('a');
    link.href = window.URL.createObjectURL(blob);                   
    link.download = fileName;
    link.click();

【问题讨论】:

    标签: javascript ajax bootstrap-modal


    【解决方案1】:

    您在window.URL.createObjectURL 中使用了blob,这是未定义的。

    您可以使用this 解决方案。

    使用这样的代码:

    var newwin=window.open("",'newwindow','width=700,height=700, left=100,top=100,resizable=yes','_blank').document;
    var link =newwin.createElement('a');
    var blob = new Blob([json], {type: "octet/stream"});
    link.href = window.URL.createObjectURL(blob);                   
    link.download = fileName
    window.location.assign(url);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-25
      • 2015-07-12
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多