Callback URL

It is possible to start the scanner from a HTML page in Chrome browser, and get the result back in the same page/tab.
It can also work with the standard Android web browser, but if this web browser receives a callback with an existing URL, as if you scan the same barcode 2 times with below test page, the page will be reloaded and any state data on the page will be lost.

Syntax:

  mochabarcode://CALLBACKHASH/?url

Example:

  mochabarcode://CALLBACKHASH/?http://mochasoft.com/test1au.htm

Warning: the callbackhash syntax is different from the iOS version.

A simple HTML test1au.htm page

Source for test1au.htm:
    
    
<head>
        
<script type="text/javascript">
  function startscan() {
    barcodefieldresult.value ="";
    window.location = "mochabarcode://CALLBACKHASH/?"+window.location;
  }
  function load_from_url_callback() {
  var str1= window.location.hash.substring(1);
    if (str1) {
      var str2 = barcodefieldresult.value
      var n = str1.localeCompare(str2);
      if (n != 0)  {
         // new barcode value is ready to be processed
         var y = str1.split("?MTIMEX");
         barcodefieldresult.value = y[0];
      }
   }
  }
        
  var x = setInterval(function() {
    load_from_url_callback()
  },1000);
                            
                            
</script>
</head>
<body>
        
  <h3>Barcode test page with callback , using callback to same page</h3>
  <input onclick="startscan()" type="button" value="Start mocha barcode scanner app" /> <<br>
  <br>
  <h3>Result:</h3>
  <input id="barcodefieldresult" /><br />
</body>
</html>