从Web应用程序中的任何网页捕获扫描的条形码 [英] Capture scanned barcode from any web page in web application

查看:388
本文介绍了从Web应用程序中的任何网页捕获扫描的条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我继承的webapp中,有一些jquery代码可以捕获条形码扫描(简单的一维条码,如健身俱乐部和杂货店使用 - 没有QR码,没有异国情调等)。但实现它的方式需要一个模态框来设置一个微调器,然后你扫描,它的工作原理。我们的客户不喜欢这样。他们希望能够从应用程序中的任何网页扫描条形码,而不必转到某个页面并在扫描之前出现模式窗口,阻止其他所有内容。

In the webapp I inherited, there is some jquery code that captures a barcode scan (simple 1-D barcode like fitness clubs and grocery stores use -- no QR codes, nothing exotic, etc). But the way this is implemented requires a modal box to come up with a spinner on it, then you scan, and it works. Our customers don't like this. They want to be able to scan the barcode from any web page in the app, and not have to go to a certain page and have a modal window come up, blocking everything else, before scanning.

我对此感兴趣: https://github.com / julien-maurel / jQuery-Scanner-Detection (我无法让它工作。)我在网页上试过这个:

I have looked at this with interest: https://github.com/julien-maurel/jQuery-Scanner-Detection (I just can't get it to work.) I have tried this in a web page:

<script type="text/javascript" src="Scripts/barcode/jquery.scannerdetection.js"></script>
<script>
    $(window).bind('scannerDetectionComplete', function (e, data) {
        alert(e);
        alert(data);
    })
</script>

我也试过 $(文件).bind(...) 代替

实际的源文档只是说做 $(选择器).scannerDetection(); 他们没有给出实际用法的例子。

The actual source docs merely say to do $(selector).scannerDetection(); They give no examples of actual usage.

我真的不在乎我是否使用这个jquery插件,其他一些jquery插件,自定义jquery,或者一些原始的javascript代码片段 - 我只需要能够从任何网页检测条形码扫描而不需要求助于模态监听器的东西。如果有人知道如何使用jQuery-Scanner-Detection插件(如上所述),我也很乐意尝试。谢谢。

I really don't care whether I use this jquery plugin, some other jquery plugin, custom jquery, or some raw javascript code snippet -- I just need something that will detect a barcode scan from any web page without resorting to a modal listener. If someone knows how to get "jQuery-Scanner-Detection" plugin (mentioned above) to work, I'd love to try that as well. Thank you.

推荐答案

文件准备好了;)

jQuery(document).ready(function($) {

    $(window).scannerDetection();
    $(window).bind('scannerDetectionComplete',function(e,data){
            alert('complete '+data.string);
        })
        .bind('scannerDetectionError',function(e,data){
            console.log('detection error '+data.string);
        })
        .bind('scannerDetectionReceive',function(e,data){
            console.log(data);
        })

    $(window).scannerDetection('success');

});

这篇关于从Web应用程序中的任何网页捕获扫描的条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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