条形码扫描器在扫描时重定向到 url

Barcode Scanner to redirect to url on scan

我有一个 USB 条码扫描器,可以粘贴它扫描的条码中的数据。是否可以扫描条形码并从当前浏览器重定向到基于扫描信息的页面?这将使用 php、html 和 js

也许是这样的。

<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);
  });
});

在这里测试代码 https://codepen.io/mbzbugsy/pen/EmZPYP