与科尔多瓦3.6 InAppBrowser窗口中后退按钮的行为? [英] Back button behavior within an InAppBrowser window with Cordova 3.6?

查看:355
本文介绍了与科尔多瓦3.6 InAppBrowser窗口中后退按钮的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写用科尔多瓦3.6移动应用程序,这个应用程序只需要打开相应的到我的网站的移动版本外部URL

I'm writing a mobile application using cordova 3.6, this app just open an external url corresponding to the mobile version of my website

var ref = window.open('http://www.stackoverflow.com', '_self', 'location=no');

如果一个用_self为目标,后退按钮的行为是好的印版,因为它工作正常browesed页面内,但问题是,最后回到了做回我的索引页,然后再次打开历史堆栈我网址!还窗口上的事件不工作。如何退出?

If a use _self as the target, the back button behavior is fine forme as it works correctly within browesed pages but the problem is that the last back in the history stack done go back on my index page and then open once again my url ! Also the events on the window doesn't work. How to exit?

var ref = window.open('http://www.stackoverflow.com', '_blank', 'location=no');

如果一个用_self为目标,后退按钮的行为是不一样的。有浏览的网页内无回可能的,只是索引页面,无论我们是上一回。我怎样才能修改其行为具有相同_self?

If a use _self as the target, the back button behavior is not the same. There is no back possible within browsed pages, just a back on the index page whatever we are. How can I modify the behavior to have the same as the _self?

我坚持这两个解决方案:(

I am stuck with these 2 solutions :(

请注意:我看到这个<一个href=\"http://stackoverflow.com/questions/20497317/phonegap-inappbrowser-back-button-dont-go-to-$p$pvious-page\">similar问题但建议code

Note: I saw this similar question but the suggested code

dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    public void onDismiss(DialogInterface dialog) {     
                        closeDialog();
                    }
});

没有更多的科尔多瓦InAppBrowser.java存在不存在

no more exists in cordova InAppBrowser.java no more exist

推荐答案

我发现了_blank选项目标使用科尔多瓦3.6感谢克里斯埃里克森的回答工作的解决方案上的<一个href=\"http://stackoverflow.com/questions/16569269/handle-android-back-button-on-phonegap-inappbrowser\">this帖子

I found a working solution for the "_blank" option target using cordova 3.6 thanks to the answer of Kris Erikson on this post

通过这些修改硬件回到页面内按钮的作品在InAppBrowser。

With those modifications the hardware back button works within pages in an InAppBrowser.

我复制以后他的工作液

进入的src / COM /组织/阿帕奇/ corodova / inappbrowser目录并编辑InAppBrowserDialog.java:
更改

Go to src/com/org/apache/corodova/inappbrowser directory and edit the InAppBrowserDialog.java: Change

public void onBackPressed () {
   if (this.inAppBrowser == null) {
      this.dismiss();
   } else {
      // better to go through the in inAppBrowser
      // because it does a clean up            
      this.inAppBrowser.closeDialog();           
   }
}

public void onBackPressed () {
   if (this.inAppBrowser == null) {
      this.dismiss();
   } else {
      if (this.inAppBrowser.canGoBack()) {
         this.inAppBrowser.goBack();
      }  else {
         this.inAppBrowser.closeDialog();
      }
   }
}

然后去InAppBrowser并找到GoBack的功能,更改:

Then go to InAppBrowser and find the goBack function, change:

/**
* Checks to see if it is possible to go back one page in history, then does so.
*/
private void goBack() {
   if (this.inAppWebView.canGoBack()) {
      this.inAppWebView.goBack();
   }
}

/**
* Checks to see if it is possible to go back one page in history, then does so.
*/
public void goBack() {
   if (this.inAppWebView.canGoBack()) {
      this.inAppWebView.goBack();
   }
}

public boolean canGoBack() {
   return this.inAppWebView.canGoBack();
}

如果你找到一个更好的解决方案,避免修改Java code请发表

Please post if you find a better solution avoiding to modify the java code

这篇关于与科尔多瓦3.6 InAppBrowser窗口中后退按钮的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆