I am attempting to interact with a JavaScript API written by the handheld group. The JavaScript is interpreted using a bespoke browser based on chromium called Kiosk Browser. The documentation mentions that app functions can be set via HTML meta tags.
<meta http-equiv="ScannerNavigate" content="javascript:OnScan('%s', '%s', '%s');">
(1) barcode data, (2) symbology type, and (3) timestamp will be passed to a function with 3 arguments.
How would I attempt to interact with this function? I have assumed that if I write the implementation for the function with the correct signature, the arguments will be passed to it. If so, when does the function get called?
function OnScan(barcodeData, symbologyType, timestamp) {
// Implementation here...
}
Or would I be expected to call the function without implementation?
OnScan(barcodeData, symbologyType, timestamp);
The latter seems to be unlikely. I have tried both implementations with no luck yet.
Found that solution for anyone else interested in working with Handheld Group devices. Simply include the <meta>
tag in the <head>
of the document.
<head>
<meta charset="utf-8">
<meta http-equiv="ScannerNavigate" content="javascript:OnScan('%s', '%s', '%s');">
Implement the following function in JavaScript:
<script>
function OnScan(barcodeData, symbologyType, timestamp) {
alert(barcodeData);
}
</script>
The parameter names can be anything you like, the function is called on a successful scan with the hardware scanner and values are automatically passed to this defined function.