My code is this:
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="Full Screen">
<!-- CSS Global -->
<link href="js/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="js/style.css" type="text/css" />
<script src="/MODELO/JQM/JQ_1113min.js"></script>
<script type="text/javascript">
if(window.location.hash.substr(1,2) == "zx"){
var bc = window.location.hash.substr(3);
localStorage["barcode"] = decodeURI(window.location.hash.substr(3));
window.close();
self.close();
// window.location.href = "about:blank";//In case self.close isn't allowed
}
</script>
<script type="text/javascript" >
var changingHash = false;
function onbarcode(event){
switch(event.type){
case "hashchange":{
if(changingHash == true){
return;
}
var hash = window.location.hash;
if(hash.substr(0,3) == "#zx"){
hash = window.location.hash.substr(3);
changingHash = true;
window.location.hash = event.oldURL.split("\#")[1] || ""
changingHash = false;
processBarcode(hash);
}
break;
}
case "storage":{
window.focus();
if(event.key == "barcode"){
window.removeEventListener("storage", onbarcode, false);
processBarcode(event.newValue);
}
break;
}
default:{
console.log(event)
break;
}
}
}
window.addEventListener("hashchange", onbarcode, false);
function getScan(){
var href = window.location.href;
var ptr = href.lastIndexOf("#");
if(ptr>0){
href = href.substr(0,ptr);
}
window.addEventListener("storage", onbarcode, false);
setTimeout('window.removeEventListener("storage", onbarcode, false)', 15000);
localStorage.removeItem("barcode");
//window.open (href + "#zx" + new Date().toString());
if(navigator.userAgent.match(/Firefox/i)){
//Used for Firefox. If Chrome uses this, it raises the "hashchanged" event only.
window.location.href = ("zxing://scan/?ret=" + encodeURIComponent(href + "#zx{CODE}"));
}else{
window.open ("zxing://scan/?ret=" + encodeURIComponent(href + "#zx{CODE}"));
}
}
function processBarcode(bc){
document.getElementById("scans").innerHTML += "<div>" + bc + "</div>";
//put your code in place of the line above.
}
</script>
</head>
<body class="wide">
<!-- Wrap all content -->
<div class="wrapper">
<!-- Content area-->
<div class="content-area">
<section class="page-section with-sidebar sidebar-right light">
<INPUT id=barcode type=text >
<button id="scanner" style="width:50px;height:50px" type=button value="Scan" onclick="getScan();" ></button>
<div id="scans"></div>
<!-- <a href="http://zxing.appspot.com/scan?ret={CODE}" target=""> scan </a> -->
<!-- <a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end"> Take a QR code </a> -->
</section>
</div>
</div>
</body>
</html>
What I try is simple, on a tablet with android, from a stupid html , I call the barcode scanner application to read a code and return it to me below input
.
The call to the app and the reading and the return of the code that reads does it well, the problem is that it opens a window in chrome that stays in the foreground and that I can not close and I would like it to stay in close-up the calling window.
Thanks