質問

I have a huge set of data that is exported as csv in my web application.

I will simplify it for easy understanding. Let me say that I have the following text:

text,value
Sample text,This is the #1 site for answers

Its been formatted and ready for exporting as csv. Before that, I encode it using encodeURI() and then I assign it to the href attribute of an anchor tag as:

data:text/csv;utf-8,<the encoded string goes here>

The issue is that only when the string contains a #, only in Firefox, the entire CSV file is not downloaded. Only upto the row previous to the row containing # is downloaded. This happens only in firefox.

If I replace the # with an alphabet, everything is fine. The hash character upsets the download - only in firefox.

役に立ちましたか?

解決

Use the encodeURIComponent function.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top