使用iframe的文件下载在Iphone/Ipad中不起作用 [英] File Download using iframe not working in Iphone/Ipad

查看:511
本文介绍了使用iframe的文件下载在Iphone/Ipad中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MVC-Bootstrap Web应用程序无法使用文件下载功能,该Web应用程序在Iphones/Ipads中使用iframe(适用于Safari和Chrome).一切都可以在台式机,笔记本电脑和Android设备(适用于所有浏览器)中正​​常运行.

File download feature is not working for my MVC-Bootstrap web application that uses an iframe in Iphones/Ipads ( for both Safari and Chrome). Everything works well in desktops,laptops and in Android devices ( for all browsers).

单击按钮后,我使用下面的Jquery代码调用iframe下载PDF

In a button click, I use the below Jquery code to invoke an iframe to download a PDF

 $("#iframedownload").attr("src", downloadURL);

downloadURL指向具有用于下载文件的代码的页面.

downloadURL points to the page that has the code to download the file.

下载文件的代码

return File(filebyteArray, "application/pdf", string.Format("Myfile.pdf", 
DateTime.Now.Ticks.ToString())); 

iframe

<iframe id="iframedownload" style="display: none"></iframe>

对此有何想法?

推荐答案

Iphone/Ipad不支持类似iframe的下载方法

Looks like iframe download approach is not supported in Iphone/Ipad

改为使用 window.location

window.location = "@Url.Action(Action, Controller)";    

这篇关于使用iframe的文件下载在Iphone/Ipad中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆