Callback URL using hash character (From v 1.7)

It is possible to start the scanner from a HTML page in Safari, and get the result back in the same page/tab.
If Safari 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/test2a.htm

A simple HTML test2a.htm page

Source for test2a.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
        barcodefieldresult.value = str1;
      }
    }
  }
        
  var x = setInterval(function() {
    load_from_url_callback()
  },1000);
                            
                            
</script>
</head>
<body>
        
  <h3>Barcode test page with callback , using callback to same page and # parameter</h3>
  <input onclick="startscan()" type="button" value="Start mocha barcode scanner app" /> <<br>
  <br>
  <h3>Result:</h3>
  <input id="barcodefieldresult" /><br />
</body>
</html>