2
我試圖實現2條碼掃描儀到2個不同的按鈕。問題是,當我按下一個或另一個按鈕時,兩個腳本都與每個按鈕一起使用。我需要將它們分開嗎?英特爾xdk 2條碼掃描儀
按鈕1:
<a class="uib-graphic-button default-graphic-sizing default-image-sizing hover-graphic-button active-graphic-button default-graphic-button default-graphic-text widget uib_w_52 d-margins skenavimo_tekstas media-button-text-bottom" data-uib="media/graphic_button"
data-ver="0" id="scan1" style="position: relative; display:block; float:center; width: 10%; padding-bottom: 10%;
width: 50%; margin: 0 auto; " onclick="scanNow();">
按鈕2:
<a class="button widget uib_w_54 d-margins testas icon camera yellow" data-uib="app_framework/button" data-ver="1" id="scan2" onclick="scanNow2();">Scan</a>
SCRIPT1:
<script>
function scanNow()
{
//this function launches the QR Code scanner.
intel.xdk.device.scanBarcode();
}
document.addEventListener("intel.xdk.device.barcode.scan",function(evt){
if (evt.success == true) {
//successful scan
alert("I'm number 1");
}
else
{
//failed scan
alert("ERROR");
}
},false);
</script>
SCRIPT2:
<script>
function scanNow2()
{
//this function launches the QR Code scanner.
intel.xdk.device.scanBarcode();
}
document.addEventListener("intel.xdk.device.barcode.scan",function(ted){
if (ted.success == true) {
//successful scan
alert("I'm nubmer 2");
}else{
//failed scan
alert("ERROR");
}
},false);
</script>
非常感謝你!!!!現在它可以工作。 – dziugas009