是否可以从跨浏览器跨操作系统的 Web 应用程序访问 USB?
我想知道是否有办法可以实现这一目标。我听说过有关 Silverlight 4、JavaScript 或 ActiveX 控件的不同说法,但我还没有看到它们的任何代码演示。
是否有可用的 Web 组件或者我该如何编写一个?
我们非常喜欢通过网络捕获客户端的 USB 驱动器并在其上读/写数据。这必须适用于任何操作系统和任何网络浏览器。
浏览器模式下的 WPF 怎么样?我读到我可以在浏览器中托管我的 WPF 应用程序,有点像智能客户端。
这是通过 Silverlight 4 执行此操作的一个很好的示例,但作者提到了通过以下方式访问 Mac 上 USB 的可能性:
启用执行 AppleScript 脚本。 此选项将使我们在 Mac 计算机上拥有与 Windows 计算机上相同的控制权。
向 ComAutomationFactory.CreateObject() 添加一个重载,该重载在场景下调用“Tell Application”命令并获取 AppleScript 对象。 此选项非常适合 Microsoft Office 自动化。对于任何其他操作系统功能,您必须对操作系统访问进行两次编码。
我不太明白。有人尝试过这个吗?
I am wondering if there is a way we can achieve this. I heard different things about Silverlight 4, JavaScript or ActiveX control, but I have not seen any demo of code for any of them.
Is there a web component that is available or how can I write one?
We really like to capture a client's USB drive via the Web and read/write data on it. This has to work for any operating system in any web browser.
What about WPF in browser mode? I read that I can host my WPF applications inside browser and sort of like smart client.
Here is a great example of doing this via Silverlight 4, but the author mentions about possibility of accessing USB on Mac via:
Enable executing AppleScript scripts.
This option will let us have the same amount of control on a Mac machine as we do on a Windows machine.Add an overload to ComAutomationFactory.CreateObject() that calls the “Tell Application” command under the scenes and gets a AppleScript object.
This option would work extremely well for Microsoft Office automation. For any other operating system feature, you’ll have to code the OS access twice.
I did not quite understand it. Has any tried this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
出于安全原因,Web 浏览器故意与文件系统隔离。只有Java(不是“Java Script”)、Flash 或浏览器插件可以完成此操作。
Web browsers are deliberately isolated from the filesystem for security reasons. Only Java (not "Java Script"), Flash or browser plug-ins can accomplish this.
出于安全原因,JavaScript 无法直接访问您的本地磁盘(包括闪存驱动器)(您真的希望您所查看的任何网站访问、更改甚至删除您的文件吗?),并且 ActiveX 控件是 IE 特定的,因此您也许应该使用 Java 小程序(而不是 JavaScript)。虽然 Java 的安全策略通常不允许访问本地磁盘,但签名的小程序可以在用户许可的情况下。
JavaScript cannot directly access your local disk (including a flash drive) for security reasons (would you really want any web site you look at to access, change, or even delete your files?), and ActiveX controls are IE-specific, so you should probably use a Java applet (not JavaScript). While Java's security policy normally does not allow access to local disks, signed applets can with the user's permission.
如果您愿意引入对 Flash (10) 的依赖项,则可以使用 FileReference 类一次访问一个文件,首先使用 浏览 方法,然后使用 保存 方法。
请注意,出于安全原因,对这些方法的每次调用都必须通过用户输入(例如单击按钮)来触发,并且每次调用它们时都会显示操作系统特定的文件打开/另存为对话框。
有一个视频教程,它提供了一些用于编辑文本文件的示例代码(加载+直接在 Flash 中保存),无需任何服务器端帮助。这应该足以让您朝着正确的方向开始。
If you're willing to introduce a dependency on Flash (10), you can use the FileReference class to get access to one file at a time, first for reading using the browse method, then for writing using the save method.
Note that for security reasons, each call to these methods must be triggered as a result of user input (e.g. clicking a button), and each time they are called an OS-specific File Open/Save As dialog box is displayed.
There's a video tutorial which gives some sample code for editing a text file (load + save) directly in Flash, without needing any server-side help. It should be enough to get you started in the right direction.
浏览器模式下的 WPF 怎么样...我读到我可以在浏览器中托管我的 wpf 应用程序,有点像智能客户端。
What about WPF in browser mode...I read that I can host my wpf apps inside browser and sort of like smart client.