title: Google script html service with Zxing bar code scanner
body: <p>I have the following script running through Google Script HTML service. The plan is to use it on our Android phones to call the Zxing QR scanner and then return the value from the scan. I would then have script to put the QR into a Google spreadsheet. This Script throws an error when run through Google Apps script HTML on an Android device. Thanks for your help!</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;body style="margin:0px;font-family:tahoma" onhashchange="getHash()"&gt;
  &lt;input id=barcode type=text &gt;
  &lt;input style="width:100px;height:100px" type=button value="Scan" onclick="getScan()"&gt;
  &lt;p id="message"&gt;&lt;/p&gt;
  
  &lt;script type="text/javascript" &gt;
  
  function getScan(){
      var href=window.location.href;//works
      var ptr=href.lastIndexOf("#");
      if(ptr&gt;0){
          href=href.substr(0,ptr);
      }
        window.location.href="zxing://scan/?ret="+escape(href+"#{CODE}");
  
  }
  var changingHash=false;
  function getHash(){
      if(!changingHash){
          changingHash=true;
          var hash=window.location.hash.substr(1);
          document.getElementById('barcode').value=unescape(hash);
          window.location.hash="";   
          changingHash=false;
        }else{
          message.innerHTML = "Input " +  document.getElementById('barcode').value;
          //Do something with barcode here
        }
  }
  &lt;/script&gt;
  &lt;body&gt;
  &lt;/html&gt;
  </code></pre>