Javascript 如何在 HTML5 网站中创建二维码阅读器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11625415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 06:34:55  来源:igfitidea点击:

How to create a QR code reader in a HTML5 website?

javascripthtmlqr-code

提问by Binay

I was looking for possibility to create QR code reader in my HTML5 based web page. I've done some googling and all the links point me to the mobile applications.

我一直在寻找在我的基于 HTML5 的网页中创建二维码阅读器的可能性。我做了一些谷歌搜索,所有的链接都指向移动应用程序。

Please help me with some pointers as to how I can use HTML5 and JavaScript to read a QR code containing a url and then redirect the browser to that URL.

请帮助我提供一些关于如何使用 HTML5 和 JavaScript 读取包含 url 的二维码,然后将浏览器重定向到该 URL 的指针。

采纳答案by Terence Eden

There aren't many JavaScript decoders.

JavaScript 解码器并不多。

There is one at http://www.webqr.com/index.html

http://www.webqr.com/index.html有一个

The easiest way is to run ZXingor similar on your server. You can then POST the image and get the decoded result back in the response.

最简单的方法是在您的服务器上运行ZXing或类似程序。然后,您可以发布图像并在响应中返回解码结果。

回答by prespic

The jsqrcode library by Lazarsoft is now working perfectly using just HTML5, i.e. getUserMedia(WebRTC). You can find it on GitHub.

Lazarsoft 的 jsqrcode 库现在仅使用 HTML5 即可完美运行,即getUserMedia(WebRTC)。您可以在 GitHub 上找到它

I also found a great fork which is much simplified. Just one file (plus jQuery) and one call of a method: see html5-qrcode on GitHub.

我还发现了一个很棒的叉子,它被大大简化了。只有一个文件(加上 jQuery)和一个方法调用:参见GitHub 上的 html5-qrcode

回答by reicek

Reader they show at http://www.webqr.com/index.htmlworks like a charm, but literaly, you need the one on the webpage, the github version it's really hard to make it work, however, it is possible. The best way to go is reverse-engineer the example shown at the webpage.

他们在http://www.webqr.com/index.html 上展示的阅读器 就像一个魅力,但从字面上看,你需要网页上的那个,github 版本真的很难让它工作,但是,这是可能的。最好的方法是对网页上显示的示例进行逆向工程。

However, to edit and get the full potential out of it, it's not so easy. At some point I may post the stripped-down reverse-engineered QR reader, but in the meantime have some fun hacking the code.

但是,要对其进行编辑并充分发挥其潜力,并不是那么容易。在某些时候,我可能会发布精简的逆向工程 QR 阅读器,但同时也有一些乐趣破解代码。

Happy coding.

快乐编码。

回答by Burgi

The algorithm that drives http://www.webqr.comis a JavaScript implementation of https://github.com/LazarSoft/jsqrcode. I haven't tried how reliable it is yet, but that's certainly the easier plug-and-play solution (client- or server-side) out of the two.

驱动http://www.webqr.com的算法是https://github.com/LazarSoft/jsqrcode的 JavaScript 实现。我还没有尝试过它有多可靠,但这肯定是两者中更简单的即插即用解决方案(客户端或服务器端)。