简体   繁体   中英

Window.close not working on android in app browser

Is there a way to close the in app browser? window.close is only working on iOS device, and it doesn't work in Android. I've tried using window.top.close and window.open("","_self") window.close and none of it is working. I've tried to look for which browser does Viber and Line use internally but they don't have any documentation

You can try this:

var win=window.open( "myurl", "_blank");
win.addEventListener( "loadstop", function(){
       var loop = window.setInterval(function(){
           win.executeScript({
                   code: "window.shouldClose"
               },
               function(values){
                   if(values[0]){
                     win.close();
                     window.clearInterval(loop);
                   }
               }
           );
       },100);
   });

In your called window, simply do this, When you want to close it

window.shouldClose=true

I am adding this just for future references. You can set window.location.href to Viber deep link like viber://pa?chatURI=<URI> to navigate back to chat window. Here is the doc page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM