Imagine a FTP client written in HTML and JavaScript. This part works. But it would be nice if user can "copy the listing" into clipboard. Turns out that clipboard stuff is not so easy in JS (besides, listings can be huge). So better is to pop up a window with the generated listing, then user can chose to Copy'Paste, or Save the page to disk.
Currently I do:
my_window = window.open("", "Copy List"); my_window.document.write('<pre>\n'+string+'</pre>'); my_window.document.close();
Which works. I get a new tab, and the listing I have generated in "string" displays nicely.
But Chrome disables/greyes-out the "Save Page" option. It would be nice if user can save the page (html or txt). What magic is required to open a window/tab and let them save the content?
Since we use WebSockets (key1/key2) this only works in Chrome, no other browsers needed.
Way after the fact but you can use a data URI for this:
window.open("data:text/plain;base64,"+btoa(theCode))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With