File Download using iframe not working in Iphone/Ipad

北城以北 提交于 2020-01-04 07:54:59

问题


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).

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

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

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

Code to download file

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

Iframe

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

Any thoughts on this ?


回答1:


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

Use window.location instead

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


来源:https://stackoverflow.com/questions/48340337/file-download-using-iframe-not-working-in-iphone-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!