0

Mi código es éste:

<!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>

Lo que intento es simple, en una tableta con android, desde un html tonto, llamo a la aplicación barcode scanner para que lea un código y me lo devuelva debajo del input.

La llamada a la app y la lectura y la devolucion del código que lee lo hace bien, el problema es que me abre una ventana en chrome que se queda en primer plano y que no consigo cerrar y me gustaría que se quedase en primer plano la ventana llamadora.

Gracias

3
  • primero podrias definir tu ventana algo asi: myWindow = window.open("", "miVentana", "width=200, height=100");... con la ruta y todo lo que desees hacer en ella el 19 jul. 2018 a las 14:01
  • la ventana la cerrarias algo asi ...myWindow.close(); luego de que hayas leido tu codigo el 19 jul. 2018 a las 14:01
  • Buenas, gracias por tu respuesta. Sigue sin funcionar...se cierra la ventana pero la App chrome sigue abierta...
    – kannario
    el 4 sep. 2018 a las 14:44

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.