Is that possible to provide javascript API to control USB, LPT, COM devices?

点点圈 提交于 2019-12-13 02:27:50

问题


I have a computer running windows and connected with many devices, such as printer, RFID reader, etc. I want all my apps run as HTML, CSS, Javascript, so I need to access these devices through Javascript. But I don't know if it is possible to add custom Javascript API to browser (such as IE or Firefox), or what work are needed to make this possible.

Thanks


回答1:


You can use a browser's basic printing abilities to control a printer and may be able to find a keyboard wedge RFID reader, both of which would allow you to use just basic JS to operate them. However, you more than likely will need an ActiveX control (COM component) that you can instantiate from a browser script to be able to have any real control over the devices.

Unfortunately, you may have to write those controls yourself. You might be able to do it in C# with some judicious use of P/Invoke, however.




回答2:


Another possibility is to write a browser plug-in that would act as a helper. I believe browser plug-ins, such as ones for Firefox, have more free reign access to your physical machine. It could accept commands from your website to be executed outside of the browser's JavaScript sandbox. Also I believe you can write browser plug-ins for Firefox in JavaScript.



来源:https://stackoverflow.com/questions/4242153/is-that-possible-to-provide-javascript-api-to-control-usb-lpt-com-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!