在 Phonegap InAppBrowser 上处理 Android 后退按钮
我想在 InAppBrowser 上导航页面时禁用或覆盖 Android 后退按钮.我可以添加一个可以处理的事件侦听器吗?
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?
查看@T_D 下面提供的解决方案的答案是我能得到的最接近的答案.似乎不可能覆盖 InAppBrowser 中的按钮,因为在此插件上导航页面时所有 PhoneGap 调整都停止工作.除了修改 API 库之外,我找不到任何其他解决方案.如果这里有任何 PhoneGap 人并且了解更多信息,我会很高兴得到一些评论.谢谢.
Looking at the answer by @T_D below the solutions provided are the closest I could get to. It does not seem to be possible to override the button in InAppBrowser as all the PhoneGap tweaks stop working while navigating pages on this plugin. I was not able to find any other solution rather than modifying the API library. If there are any PhoneGap guys here and know something more, I 'll be glad to get some comment. Thanks.
我得到的最近的:
var ref = window.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener("backbutton", function () { })
根据文档 现在可以为 InAppBrowser 配置硬件后退按钮的行为:
According to the documentation the behaviour of the hardware back button can be configured now for the InAppBrowser:
hardwareback:设置为 yes 以使用硬件后退按钮在 InAppBrowser 的历史记录中向后导航.如果没有上一页,InAppBrowser 将关闭.默认值为 yes,因此如果您希望后退按钮简单地关闭 InAppBrowser,则必须将其设置为 no.
hardwareback: set to yes to use the hardware back button to navigate backwards through the InAppBrowser's history. If there is no previous page, the InAppBrowser will close. The default value is yes, so you must set it to no if you want the back button to simply close the InAppBrowser.
感谢克里斯·埃里克森.
因此,如果向后导航是所需的行为,只需更新您的 InAppBrowser 插件.
So just update your InAppBrowser plugin if the backward navigation is the desired behaviour.
更多详情参见:https://github.com/apache/cordova-plugin-inappbrowser/pull/86