JS File Export
For js export files, you can use the ActiveXObject object in IE to save them. IE is something from Microsoft, so this is normal. But this is a headache for other browsers. After some online materials and some of my own attempts, I found FileSaver. js, which is very convenient to use. FileSaver. js is a type of HTML-based file storage, and natural HTML is also a trend.
The following shows how FileSaver. js supports some mainstream browsers.
Some browsers with poor support also provide a response solution. If necessary, go to the official address. With the help of blob objects, FileSaver. js loads Blob. js and FileSaver. js, and then directly calls to save the file. If the output content contains Chinese characters, add? To prevent Chinese garbled characters.
Var BB = self. Blob; saveAs (new BB ([? + Content] //? Prevent utf8 bom from Chinese garbled characters, {type: text/plain; charset = utf8}), demo.csv );Output document content. Here I output a csv file and an excel form.