JavaScript代码保存一个txt文件 [英] javascript code to save a txt file

查看:122
本文介绍了JavaScript代码保存一个txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在创建文件后,它将保存为诊断对话框。

可以任何机构告诉我如何使用JavaScript兼容浏览器来创建.txt文件。所以我可以保存创建的文件。



其他任何逻辑也是很好的



我在做它在IE中很好,



但是相同的代码没有在其他浏览器中运行

解决方案


你不能这样做,因为有希望的安全原因。 JavaScript
无法访问文件系统......在IE中它不是JavaScript,而是
ActiveX这样做......它只是暴露了一个JavaScript API。



问题不是Firefox不这样做......它是IE
允许它:)

在这篇文章中在Firefox中,使用写入文件Javascript?


can any body tell me how i create a .txt file using javascript which is browser compatable too.

and after creating the file it gives the save as diaglog box so that i can save the file that is created.

any other logic is also wellcome

i am doing it well in IE,

but the same code isn't running in the other browsers

解决方案

You can't do this, for hopefully obvious security reasons. JavaScript has no access to the file system...in IE it's not JavaScript, but ActiveX doing this...it just has a JavaScript API exposed.

The problem isn't that Firefox doesn't do this...it's that IE ever allowed it :)

In this post In Firefox, Write to a File using Javascript?

这篇关于JavaScript代码保存一个txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆