admin管理员组文章数量:1390391
I am looking for a way to save a couple of files created with JavaScript on the clients puter. I want him to be able to choose a folder (similar to open/save folder dialog), and then write the files there. This obviously requires three things:
- Ability to popup such a dialog.
- Ability to write on the client's puter (signed applets?)
- Some way to interact with JavaScript because it knows the filenames and contents to write.
Is this possible or should I just stop dreaming?
I am looking for a way to save a couple of files created with JavaScript on the clients puter. I want him to be able to choose a folder (similar to open/save folder dialog), and then write the files there. This obviously requires three things:
- Ability to popup such a dialog.
- Ability to write on the client's puter (signed applets?)
- Some way to interact with JavaScript because it knows the filenames and contents to write.
Is this possible or should I just stop dreaming?
Share Improve this question edited Jun 8, 2012 at 7:51 Andrew Thompson 169k41 gold badges222 silver badges436 bronze badges asked Jan 31, 2011 at 18:51 TowerTower 103k131 gold badges364 silver badges521 bronze badges3 Answers
Reset to default 3It sure is possible.
One way is to use a signed applet, but if your users are willing to upgrade to Java 1.6.0_10+, a signed applet is not needed. Since 1.6.0_10 (the Next Generation Java Plug-In), JNLP API services are available to embedded applets. Here is a demo. of the JNLP file services.
I see the other reply has already covered the applet/JS interaction.
It is possible with a signed applet.
I'd probably do it the other way around, let the javascript code pass all the data to the applet and the applet should open a FileDialog
and write the file.
Calling javascript from java can be achieved via `JSObject, calling Java from Javascript is explained here
If your applet is signed you can do everything that you can do in regular application. You can open "File dialog" but it will be the Java's dialog, not the same that is opened when user pushes "browse" button of tag <intput type"file"/>
. Obviously signed applet can perform read and write operations with user's disk.
All applets (either signed or unsigned) may call javascript using JSObject
. You just have to say MAYSCRIPT="true" into applet tag.
I think that you cannot open the browser's "file open" dialog applet. Actually you even cannot open it using regular javascript. (I'd be happy to know that I am wrong at this point but I spent some time trying to do this and failed).
本文标签:
版权声明:本文标题:Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction? - Stack Over 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744736977a2622390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论