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 badges2 Answers
Reset to default 9Document 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
版权声明:本文标题:javascript - Capture scanned barcode from any web page in web application - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741510563a2382582.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论