Software Archive
Read-only legacy content
17061 Discussions

How to go to local html page using QR scanner pluggin?

Ananta_Teor_A_
Beginner
228 Views

Hello,

How do I scan a qr code and as soon as it finish scanning it go to a html page within the www directory of the app.

 

 

function scan() {
    "use strict";
    var fName = "scan():";
    console.log(fName, "entry");
    try {
        if (window.tinyHippos) {
            thirdPartyEmulator();
            console.log(fName, "emulator alert");
        } else {
            cordova.plugins.barcodeScanner.scan(
                function (result) {
                    //the qr code will generate profile number
                  window.location = result.text+".html";

//It work fine in the simulator

//but it keep redirecting to index.html
                },
                function (error) {
                    alert("Scanning failed: " + error);
                }
            );
        }
    } catch (e) {
        console.log(fName, "catch, failure");
    }

    console.log(fName, "exit");
}

It work fine in the simulator

but it keep redirecting to index.html

Thank you

 

 

0 Kudos
1 Reply
PaulF_IntelCorp
Employee
228 Views

The Cordova project recommends, as do we, that you implement your app as an "SPA" (a single-page app). Please see this Cordova doc for details > https://cordova.apache.org/docs/en/latest/guide/next/#1-spa-is-your-friend < the primary reason you want to do this is to avoid the loss of JavaScript context when you switch pages. Also, switching between multiple HTML files can be very "expensive" because it requires a restart of the Cordova subsystem.

For more specific help with learning how to write a Cordova app we recommend you use StackOverflow (Cordova tag) and search the Internet for the many excellent blogs on how to write Cordova applications.

0 Kudos
Reply