Javascript 如何在bootstrap模型的新窗口上显示下载提示?
对于一个普通的HTML页面,我尝试了下面的代码,它在一个单独的窗口中开始下载。当我对引导模式表单使用相同的代码时,它就不起作用了。要在引导模式中实现相同的功能,我还需要做什么Javascript 如何在bootstrap模型的新窗口上显示下载提示?,javascript,ajax,bootstrap-modal,Javascript,Ajax,Bootstrap Modal,对于一个普通的HTML页面,我尝试了下面的代码,它在一个单独的窗口中开始下载。当我对引导模式表单使用相同的代码时,它就不起作用了。要在引导模式中实现相同的功能,我还需要做什么 var newwin=window.open("",'newwindow','width=700,height=700, left=100,top=100,resizable=yes','_blank').document; var link =newwin.createElement('a'); lin
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();
您在
window.URL.createObjectURL
中使用了blob
,但未定义您可以使用解决方案 使用如下代码:
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);