admin管理员组

文章数量:1291060

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 e 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 e up, blocking everything else, before scanning.

I have looked at this with interest: (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>

I have also tried $(document).bind(...) in place of

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

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.

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 e 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 e up, blocking everything else, before scanning.

I have looked at this with interest: https://github./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>

I have also tried $(document).bind(...) in place of

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

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.

Share Improve this question asked Oct 2, 2014 at 16:20 HerrimanCoderHerrimanCoder 7,22630 gold badges95 silver badges170 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Document ready ;)

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

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

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

});

This is how I use it and it works fine :

$(selector).scannerDetection(function(data) {

onComplete:

//whatever you want

});

I don't think it's necessary to bind it to your window or document you can straight work it with your selector.

本文标签: javascriptCapture scanned barcode from any web page in web applicationStack Overflow