Data URI file download in Interent Explorer

2019-02-25 13:10发布

问题:

I have a web based application and was looking for a way for users to download their data from the websql tables. Someone suggested using data URI which seems to work in all browsers but Internet Explorer. The approach I am taking is to store all data in a variable and using text/csv MIME-Type and charset=UTF-8 character set encoding:

document.location.href = 'data:text/csv;charset=UTF-8,' + encodeURIComponent(info);

However when I click the link in internet explorer 9 it says the page can not be displayed. Any ideas how to get this working in IE? Thanks.

回答1:

IE8 and IE9 only support the data URI for images. Read more about IE's support for the data URI here:

http://msdn.microsoft.com/en-us/library/cc848897(v=vs.85).aspx

EDIT: You could try some kinda flash hack for IE. Pass the data to flash. Use AS3 to initiate a download.