我var a = 'Hello World From Javascript';
在当前窗口的 javascript 变量中有一些文本数据(比如)。我想通过javascript执行以下操作-
1. open a new window and write the text data to the window.
2. set the content type to text/plain.
3. set the content-disposition to attachment, so that download prompt comes.
4. user downloads the text data as a text file and saves it to his local disk.
这一切都可以通过javascript实现吗?
我知道我们可以对服务器进行 ajax 调用或重定向,但在这种情况下,而不是遵循上述步骤。但在这种情况下,这些变通办法是不适应的。