Download textarea contents as a file using only Javascript (no server-side)

前端 未结 8 2336
挽巷
挽巷 2020-11-29 03:44

I am being asked to make a \"download\" button that downloads the contents of a textarea on the same page as a file, with the browser\'s \"Save As...\" dialog showing up. Co

8条回答
  •  忘掉有多难
    2020-11-29 04:12

    It might be possible by creating a frame, writing contents there, then calling document.execCommand('saveas', ...) in IE and something with nsIFilePicker in Mozilla, but I believe that would require some extraordinary privileges (like being part of the browser itself).

提交回复
热议问题