Handle Android Back Button on Phonegap InAppBrowser

后端 未结 9 762
小鲜肉
小鲜肉 2020-12-09 21:41

I would like to disable or override the Android Back button while I am navigating pages on the InAppBrowser. Can I add an event listener that can handle that?

9条回答
  •  一个人的身影
    2020-12-09 21:51

    Running Cordova 5.1.1 and when i load pages in the inappbroswer i like having the back button work until the inappbrowser exits back to my index.html page because it's blank and just sits there. So i used the following code to fix this. It exits the app when it exits the inappbrowser.

    window.open = cordova.InAppBrowser.open;                
                var ref = window.open(url, '_blank', 'location=no');
                ref.addEventListener('exit', function () {
                    navigator.app.exitApp();
                });
    

提交回复
热议问题