科尔多瓦在设备浏览器打开一个网页 [英] Cordova opening a web page in device browser
问题描述
好吧,我有一个problem.Currently我已经编辑我CordovaWebView.java类,这样,当我preSS装置后退按钮,应用程序将被要求关闭。
Ok i have a problem.Currently i have edited my CordovaWebView.java class so that when i press the device back button,the application will be asked to close.
public boolean backHistory() {
// Check webview first to see if there is a history
// This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
if (super.canGoBack()) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Sign out Confirm")
.setMessage("Are you sure you want to logout?")
.setCancelable(false)
.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
cordova.getActivity().finish();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
}).show();
// super.goBack();
return true;
}
return false;
}
所以,当我从我的应用程序中打开一个新的网页,它只是打开我的应用程序本身内部的网页。所以,我没有办法回去,我去我的网页后,因为该应用程序会被要求关闭,因为我已经做的编辑。
So when i'm opening a new web page from my application it just opens the web page inside my application itself. So i dont have a way to go back after i go to my web page because the application will be asked to close because of the edits i have done.
有没有办法在设备浏览器中打开一个网页或者我可以做一个额外的编辑回去当一个网页被打开。
Is there a way to open a web page in device browser OR can i make a additional edit to go back when a web page is opened.
我想这些方法在设备布劳尔打开,但没有奏效。
i tried these methods to open in device brower but did not work.
var url = $state.href('myroute', {parameter: "parameter"});
window.open("https://www.google.lk/",'_system');
window.open('http://www.myurl.nl', '_system', 'location=yes');
navigator.app.loadUrl("http://google.com", {openExternal : true});
在此先感谢
推荐答案
您必须使用inAppBrowser插件 https://github.com/apache/cordova-plugin-inappbrowser
You have to use inAppBrowser plugin https://github.com/apache/cordova-plugin-inappbrowser
然后就可以使用这个code打开外部浏览器:
Then you can use this code to open the external browser:
var ref = window.open('http://apache.org', '_system', 'location=yes');
P.S。您不必编辑CordovaWebView.java让后退按钮的工作,你可以做到这一点与JavaScript的http://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#backbutton
这篇关于科尔多瓦在设备浏览器打开一个网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!