【发布时间】:2017-04-26 18:22:30
【问题描述】:
我有一个 USB 条形码扫描仪,它可以粘贴它扫描的条形码中的数据。是否可以扫描条形码并从当前浏览器重定向到基于扫描信息的页面?这将使用 php、html 和 js
【问题讨论】:
标签: javascript php qr-code barcode-scanner
我有一个 USB 条形码扫描仪,它可以粘贴它扫描的条形码中的数据。是否可以扫描条形码并从当前浏览器重定向到基于扫描信息的页面?这将使用 php、html 和 js
【问题讨论】:
标签: javascript php qr-code barcode-scanner
可能是这样的。
<h3>Barcode</h3>
<textarea class="bcode" name="barcode"></textarea>
<span class="action"></span>
一些js来处理动作
$(function() {
$('.bcode').on('paste',function(){
var _this = this;
setTimeout(function(){
//now do something with the paste data
window.location = "https://www.google.se/search?q=" + _this.value;
},1000);
});
});
【讨论】:
keyup,并将超时保存到变量中,以便可以取消任何前面的条目。
$(function() { var _timer = null; $('.bcode').on('keyup', function() { var _this = this; if (_timer !== null) clearTimeout(_timer); _timer = setTimeout(function () { window.location = "https://www.google.se/search?q=" + _this.value; }, 500); }); });