javascript - Triggering a file download without any server request -
Greetings,
I'm working on a JS-based application that does some complex work and Logs My goal is "Save Log" button that triggers the browser's download dialog I am searching on this site, on WHATWG and W3C sites and generally without success on the Web. Is this all possible? The closest I've found is using & lt; Div & gt; Some information on (in fact, up to hundreds of rows).
text / plain
, therefore the browser might suggest normal actions (such as "Open on Notepad") as if with normal file downloads. It can be seen as the specific aspect of the first requirement. & lt; Div & gt; It is definitely terrible to say that a content of
copy and paste in a text editor is definitely terrible, and this is the reason I am trying to escape. data:
url. My first try, could not get the content type through a post operation, so it returned to the UA mutation. Send me a & lt; A & gt; By looking at the link as a button and giving it a
type
attribute, it gets a bit better, but again the UA will play very smart and instead of saving the content (and the user At that step, worse than getting the copy-paste approach by asking the browser to save the file, the page's savings vary deeply between browsers).
Unfortunately this is not something you can do with normal browser capabilities. Like a flash or browser-specific plug-in you'll find something you need, but security limits within JavaScript will not allow you to download arbitrary data created within the browser.
Apart from this, the 'data' url is not supported in all browser / version combinations. I'm not sure whether your users are complying with what browser they are using or not, but what can you do with that solution?
Comments
Post a Comment