Cordoba opens a web page in the device browser

I have a problem. Currently, I have edited my CordovaWebView.java class, so when I click the device return 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 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 open a new web page from my application, it just opens the web page inside my application itself. Therefore, I do not have the opportunity to return after I go to my web page, because the application will be asked to close due to changes that I made.

Is there a way to open a webpage in a device browser. Or I can do additional editing to return when the web page opens.

I tried opening these methods in the device’s browser, but it didn’t 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}); 

Thanks in advance

0
android angularjs cordova
source share
1 answer

You should use the inAppBrowser plugin https://github.com/apache/cordova-plugin-inappbrowser

Then you can use this code to open an external browser:

 var ref = window.open('http://apache.org', '_system', 'location=yes'); 

PS you do not need to edit CordovaWebView.java to do the reverse button, you can do it using javascript http://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#backbutton

0
source share

All Articles