问题
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