Scan QR Code open Link p

1.1k Views Asked by At

Instead of opening an alert in the following Javascript code I want to redirect to a URL where the URL is imported from a QR-Code scan but sadly am no good with Javascript. Any help?

<script type="text/javascript" charset="utf-8">
function scanCode(){
        cordova.plugins.barcodeScanner.scan(
          function (result) {
              setTimeout(function() {alert('Very good. ' + result.text);}, 500);
          }, 
          function (error) {alert("Scanning failed: " + error);
          }
       );
    }
</script>
1

There are 1 best solutions below

0
On

Version with a redirection as an HTTP redirect :

<script type="text/javascript" charset="utf-8">
function scanCode(){
        cordova.plugins.barcodeScanner.scan(
          function (result) {
              setTimeout(function() {windows.location.replace(result.text);}, 500);
          }, 
          function (error) {alert("Scanning failed: " + error);
          }
       );
    }
</script>   

Version with a redirection as clicking on a link :

<script type="text/javascript" charset="utf-8">
function scanCode(){
        cordova.plugins.barcodeScanner.scan(
          function (result) {
              setTimeout(function() {windows.location.href(result.text);}, 500);
          }, 
          function (error) {alert("Scanning failed: " + error);
          }
       );
    }
</script>