PhoneGap的InAppBrowser - 后退按钮不去previous页 [英] Phonegap InAppBrowser - back button don't go to previous page
问题描述
我用的PhoneGap为我的应用程序,我需要显示在InAppBrowser外部链接 但它看起来像背钮不工作的期望:如果我做
I'm using Phonegap for my application and I need to display an external link in a InAppBrowser but it looks like the back botton is not working as expecting: if I'm doing
var ref = window.open('www.example.com/a.html' , '_blank', 'location=no')
从 a.html 页我点击一个链接的 www.example.com/b.html 下一次,当我点击回来,InAppBrowser被关闭,但它应该回去 a.html
from from a.html page I clicked a link to www.example.com/b.html next time when I click back, the InAppBrowser is closed but it should go back to a.html.
你知不知道我怎样才能使浏览历史为InAppBrowser?
Do you know how can I enable the 'navigation history' for InAppBrowser?
感谢你。
推荐答案
这是可以通过调整InAppBrowser.java。我知道这是有点怪,但是这是唯一的选择,我有。但是,这些小的调整我对Java文件所做的,现在让我来导航回到我的应用程序的页面中。
This is possible by tweaking the 'InAppBrowser.java'. I know this is little weird but this is the only choice I had. But, those little tweaks I made to the java file now allows me to navigate back within the pages in my app.
下面是InAppBrowser.java要做出的改变,在showWebPage方法中的运行的方法,将有听众code是这样的:
Here is the change to be made in InAppBrowser.java, In the 'run' method within showWebPage method, there will be a listener code something like this:
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
closeDialog();
}
});
下面这行添加下面的code,
Below that line add the below code,
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (event.getAction()!=KeyEvent.ACTION_DOWN)
return true;
if(keyCode==KeyEvent.KEYCODE_BACK){
goBack();
return true;
}else {
return false;
}
}
});
这篇关于PhoneGap的InAppBrowser - 后退按钮不去previous页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!