Reputation: 1382
I'm working on android application with cordova
and angular
.
I try to open external link inside the webview, but it's always opens in chrome...
I tried to use:
navigator.app.loadUrl(link, {openExternal:false})
and also:
window.open(link, '_self', 'location=yes')
What i'm missing?
Thank you :)
Upvotes: 1
Views: 5115
Reputation: 234
InAppBroser should be you want. https://cordova.apache.org/docs/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html
http://cordova.apache.org/docs/en/2.5.0/cordova_file_file.md.html
// !! Assumes filePath is a valid path on the device
var fileTransfer = new FileTransfer();
var uri = encodeURI("http://some.server.com/download.php");
fileTransfer.download(
uri,
filePath,
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
}
);
Upvotes: 1
Reputation: 409
you can try use WebViewClient:
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView viewx, String urlx) {
viewx.loadUrl(urlx);
return false;
}
});
Credit goes to this post: Link should be open in same web view in Android
Upvotes: 1
Reputation: 1152
You should try :
window.open(myURL, '_blank'); => OPEN IN INAPPBROWSER
OR
window.open(myURL, '_system'); => OPEN IN SYSTEM BROWSER
ADVICE : you should try to encode your URL : myURL = encodeURI(urlStr);
Upvotes: 1