用于html5和jquery应用程序的条形码扫描程序 [英] Barcode scanner for html5 and jquery application

查看:551
本文介绍了用于html5和jquery应用程序的条形码扫描程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jquery和html进行项目。它是一个静态Web应用程序。我需要一个从产品中读取条形码扫描器条形码的jquery。需要扫描条形码而不在屏幕的任何文本框中显示代码。有人请给我一些想法或提供插件的链接(如果有的话)来克服这个问题。在此先感谢。

I am using Jquery and html for a project. It is a static web application. I need a jquery that reads barcode scanner's barcode from products. The barcode need to be scanned without displaying the code in any of the textbox in the screen. Someone please gibe me some ideas or provide me the link for plugins (if any) to overcome this. Thanks in advance.

推荐答案

试试这段代码。我知道你了解Jquery。运行此代码并在关注网页时按键盘键入任何内容并按Enter键。如果这可以使条形码阅读器做同样的事情。配置条形码阅读器以在代码读取结束时传递回车键。
Jquery库

Try this code. I assum that you know about the Jquery. Run this code and type anything from the keyboard while focusing the web page and hit enter key. If this works barcode reader do the same. Configure your barcode reader to pass enter key at the end of code reading. Jquery library

<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>

Jquery

 $(document).ready(function() {
        var barcode="";
    $(document).keydown(function(e) {

        var code = (e.keyCode ? e.keyCode : e.which);
        if(code==13)// Enter key hit
        {
            alert(barcode);
        }
        else if(code==9)// Tab key hit
        {
            alert(barcode);
        }
        else
        {
            barcode=barcode+String.fromCharCode(code);
        }
    });

    });

这篇关于用于html5和jquery应用程序的条形码扫描程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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