Callback URL

It is possible to start the scanner from another App on the iPhone or the Safari web browser.

Syntax:

  mochabarcode://RUN

will just start the barcode app. (this option was included in v 1.1)

Syntax:

  mochabarcode://CALLBACK=url

Example:

  mochabarcode://CALLBACK=http://mochasoft.com/test3.htm

A simple HTML test2.htm page, and the result page test3.htm

Source for test2.htm:
<head>
<script type="text/javascript">
  function startscan() 
  {
     window.location = "mochabarcode://CALLBACK=http://mochasoft.com/test3.htm";
  }
</script>
</head>
<body>
  <input onclick="startscan()" type="button" 
      value="Start mocha barcode scanner app" /> <br />
</body>
</html>

Source for test3.htm:
<html>
<head>
<script type="text/javascript">
 function load_from_url_callback() 
 {
   var myParam = location.search.split('BARCODE=')[1];
   if (myParam)
     barcodefieldresult.value = myParam;
 }
</script>
</head>
<body onload="load_from_url_callback()">

  <input id="barcodefieldresult" />
</body>
</html>

Function startscan() defines the callback URL to be test3.htm.

When the scan has been completed, test3.htm will be loaded in a new Safari web browser window, notice not the calling window , and onload will call javascript function load_from_url_callback(), which can read the returned barcode value from the URL.