2017-04-26 191 views
0

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

+1

代码http://stackoverflow.com/questions/8465839/integrating-barcode-scanner-into-php - 应用 – waterloomatt

回答

-1

也许这样的事情。

<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

+0

这看起来很有希望,但似乎没有在这个例子上工作。它正确扫描,但数据只填写表单,它实际上并没有重定向 – Hunterisabeast

+0

我猜你的表单被填充模仿键盘输入而不是粘贴。因此,您可能需要调整上述代码以绑定到'keyup',并将超时值保存到变量中,以便可以取消任何前面的条目。 – Aran

+0

这样的事情应该做的伎俩: '''$(函数(){ VAR _timer = NULL; $()在( 'KEYUP '函数(){ VAR _this =这个' BCODE。'。 ; if(_timer!== null)clearTimeout(_timer); _timer = setTimeout(function(){ window.location =“https://www.google.se/search?q=”+ _this.value; },500); }); });''' – Aran