How to close InAppBrowser itself in Phonegap Application?

后端 未结 3 1538
予麋鹿
予麋鹿 2021-01-17 16:14

I am developing Phonegap application and currently i am using InAppBrowser to display external pages. On some of the external pages I place a close

3条回答
  •  悲&欢浪女
    2021-01-17 16:39

    This worked for me:

    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:

    window.shouldClose=true
    

    When you want to close it

提交回复
热议问题