Currently in order to have links open in an external browser, it requires uploading different code to PhoneGap Build. For iOS the domain must be whitelisted, and for Android the domain must be unlisted.
You could make it consistent by adding an attribute to the access tag, like includeForAndroid="false", which would NOT include the access tag contents on Android, so that links would open in an external browser, just like on iOS.
You could make it consistent by adding an attribute to the access tag, like includeForAndroid="false", which would NOT include the access tag contents on Android, so that links would open in an external browser, just like on iOS.
- 134 Posts
- 0 Reply Likes
- frustrated
Posted 8 years ago
- 1911 Posts
- 199 Reply Likes
Thanks for the feedback.
We're hoping to get this straightened out in Cordova open source project: in the meantime, for PhoneGap Build, I'm thinking something like this:
That will not include the tag on Android, but will on iOS. How does that sound?
We're hoping to get this straightened out in Cordova open source project: in the meantime, for PhoneGap Build, I'm thinking something like this:
<access origin="*" onlyInBrowser="true" />
That will not include the tag on Android, but will on iOS. How does that sound?
- 134 Posts
- 0 Reply Likes
Just FYI, this is the type of trouble that this issue is causing:
http://stackoverflow.com/questions/10...
How soon will the fix be published?
http://stackoverflow.com/questions/10...
How soon will the fix be published?
- 1911 Posts
- 199 Reply Likes
Alright, I've added the fix with a slight change - the attribute is called browserOnly, rather than onlyInBrowser:
I'll update the documentation this evening - just wanted to give you a quick heads up.
<access origin="http://alunny.github.com" browserOnly="true" />
I'll update the documentation this evening - just wanted to give you a quick heads up.
- 134 Posts
- 0 Reply Likes
- 39 Posts
- 2 Reply Likes
I don't understand this well enough. Let's suppose this situation:
- I need my app to be available on iOS, Android and BlackBerry
- I need my app to be able to connect through jQuery Ajax to "*" remote servers
- I need my app to be able to open target="_blank" links to "*" remote hosts
How would I get this working?
- I need my app to be available on iOS, Android and BlackBerry
- I need my app to be able to connect through jQuery Ajax to "*" remote servers
- I need my app to be able to open target="_blank" links to "*" remote hosts
How would I get this working?
- 134 Posts
- 0 Reply Likes
Juan, we're only discussing target="_blank" links here. AJAX stuff works out of the box, as long as the API you're interacting with allows it.
I found the blog post itself to be more confusing than helpful, but look at the table in it, here: https://build.phonegap.com/blog/acces...
The important take-away is that (without the fix discussed in this thread) if you have target="_blank" links in your app, then you have two choices:
* Add an access tag for that domain, or
* Don't
If you DO add the tag, then on iOS your link will be opened in Mobile Safari, and on Android your link will be opened but it will stay in the webview that your app uses, which is a BAD thing because (a) it's an inconsistent experience for users of your app on different platforms, and (b) some of them won't realize that they have to hit the Android BACK button to get back to your application. On Blackberry it will also stay in the webview and have the same problem.
The workaround was to build your apps with a different config.xml (when using PhoneGap Build) for different platforms... thus partially negating the point of PhoneGap Build in the first place.
If you're not using PGB then this doesn't apply to you -- config.xml is not a part of vanilla PhoneGap.
I haven't played with it yet but it looks like the solution as implemented will bring this back to the ideal state: one set of code performs consistently on all devices.
I found the blog post itself to be more confusing than helpful, but look at the table in it, here: https://build.phonegap.com/blog/acces...
The important take-away is that (without the fix discussed in this thread) if you have target="_blank" links in your app, then you have two choices:
* Add an access tag for that domain, or
* Don't
If you DO add the tag, then on iOS your link will be opened in Mobile Safari, and on Android your link will be opened but it will stay in the webview that your app uses, which is a BAD thing because (a) it's an inconsistent experience for users of your app on different platforms, and (b) some of them won't realize that they have to hit the Android BACK button to get back to your application. On Blackberry it will also stay in the webview and have the same problem.
The workaround was to build your apps with a different config.xml (when using PhoneGap Build) for different platforms... thus partially negating the point of PhoneGap Build in the first place.
If you're not using PGB then this doesn't apply to you -- config.xml is not a part of vanilla PhoneGap.
I haven't played with it yet but it looks like the solution as implemented will bring this back to the ideal state: one set of code performs consistently on all devices.
- 39 Posts
- 2 Reply Likes
I know that we are just discussing target="_blank" stuff here, but access tags also relates to Ajax communication because it sets the "whitelist" of the native project (generated by PhoneGap Build).
If a remote server is not whitelisted, it can't be accessed through an Ajax request.
The problem here is the mix of target="_blank" stuff, remote server access through Ajax, PhoneGap Build default values, devices implementing different behaviour for the same config.xml stuff... Including the confusing docs on PhoneGap Build.
If a remote server is not whitelisted, it can't be accessed through an Ajax request.
The problem here is the mix of target="_blank" stuff, remote server access through Ajax, PhoneGap Build default values, devices implementing different behaviour for the same config.xml stuff... Including the confusing docs on PhoneGap Build.
- 134 Posts
- 0 Reply Likes
Juan, I'm not seeing what you're describing. I have an app with access tags to, let's say tinyurl.com; and I'm making AJAX calls to mydomain.com (jquery.ajax()). Despite the fact that mydomain.com is expressly UNlisted, my API calls have no trouble getting through.
If your AJAX/API calls are not working, it may be a server-side problem. Look into the Access-Control-Allow-Origin header.
If your AJAX/API calls are not working, it may be a server-side problem. Look into the Access-Control-Allow-Origin header.
- 1911 Posts
- 199 Reply Likes
Juan, can you post a gist/pastebin of a simple app that demonstrates this problem? On iOS I was able to have Ajax calls to arbitrary domains working so long as they were on the whitelist; on Android, the Ajax calls worked with or without the whitelist.
- 39 Posts
- 2 Reply Likes
That's exactly what I mean. As you say, domains must be whitelisted to be able to make Ajax calls on them on iOS. But if those domains are whitelisted, the behavior of open in browser/webview over those domains is compromised through different devices.
That's what I was trying to say with my previous sample situation.
I'll try to make a sample PhoneGap Build app demonstrating this issue.
That's what I was trying to say with my previous sample situation.
I'll try to make a sample PhoneGap Build app demonstrating this issue.
- 1911 Posts
- 199 Reply Likes
I see. I think this fix should help you then - if you list the domains with "browserOnly", Ajax calls will work on iOS, but the pages won't take over the webview in Android.
- 3 Posts
- 0 Reply Likes
I've noticed that PhoneGap apps on Android 2.x that use the Javascript window.open() method will always open links within the WebView, not the external browser. I think this is an Android bug, rather than a PhoneGap issue. Just thought I'd mention it.
The fix proposed here does not solve the problem: http://code.google.com/p/android/issu...
The fix proposed here does not solve the problem: http://code.google.com/p/android/issu...
- 2 Posts
- 0 Reply Likes
Checking in to see if this has been updated in the open source project or if there is another solution if we aren't using phonegap build.
Thanks!!!
Thanks!!!
- 1 Post
- 0 Reply Likes
I totally need what Juan is proposing,
Its not so difficult to open target="_blank" in a new window, no matter if link is whitelisted or not...
Please do it fast.
Its not so difficult to open target="_blank" in a new window, no matter if link is whitelisted or not...
Please do it fast.
- 7 Posts
- 1 Reply Like
function loadURL(url){
//alert(url);
navigator.app.loadUrl(url, { openExternal:true });
}
Then just add onclick="loadURL('http://www.urlhere.com')" to all the links you want to open externally. I have tested this in Android and it works!
//alert(url);
navigator.app.loadUrl(url, { openExternal:true });
}
Then just add onclick="loadURL('http://www.urlhere.com')" to all the links you want to open externally. I have tested this in Android and it works!
- 30 Posts
- 0 Reply Likes
I recently logged the issue in Apache Cordova at:
https://issues.apache.org/jira/browse...
Daniel Moret solution works indeed (with PG 2.2.0 on Android) but it complicates code quite a bit when you want to support also dynamic links and desktop browsers and iOS, etc. The config.xml solution used to work for us with PG 1.6. A.R.
https://issues.apache.org/jira/browse...
Daniel Moret solution works indeed (with PG 2.2.0 on Android) but it complicates code quite a bit when you want to support also dynamic links and desktop browsers and iOS, etc. The config.xml solution used to work for us with PG 1.6. A.R.
- 134 Posts
- 0 Reply Likes
The really sad fact here is that the solution put forth from Adobe is not working. It would be a fine solution if it worked, but it simply doesn't.
Here's what's in my config.xml file:
<!-- make twitter links open in browser, not take over the webview -->
< access origin="http://twitter.com" browserOnly="true" / >
< access origin="http://search.twitter.com" browserOnly="true" / >
< access origin="http://t.co" browserOnly="true" / >
This works as expected in iOS but for Android these links still take over the webview. If anyone from Adobe cares enough to investigate, it's app id: 261392 and I can provide an email address that you can use to login to the app and instructions on how to repro the issue.
As it is I'm going to have to figure out something else for Android and build a custom version for that platform only...
Here's what's in my config.xml file:
<!-- make twitter links open in browser, not take over the webview -->
< access origin="http://twitter.com" browserOnly="true" / >
< access origin="http://search.twitter.com" browserOnly="true" / >
< access origin="http://t.co" browserOnly="true" / >
This works as expected in iOS but for Android these links still take over the webview. If anyone from Adobe cares enough to investigate, it's app id: 261392 and I can provide an email address that you can use to login to the app and instructions on how to repro the issue.
As it is I'm going to have to figure out something else for Android and build a custom version for that platform only...
- 6 Posts
- 0 Reply Likes
Folks...just in case it's of use, quick block of JS / JQuery to apply to any container within which you want to all the links to open externally (which was my scenario):
$("#xyz a").each(function(index) {
$("#xyz a").attr("onclick", "loadURL('" + this.href + "')");
$("#xyz a").attr("style", "text-decoration: underline");
$("#xyz a").removeAttr("href");
});
...and include the following function...
function loadURL(url){
navigator.app.loadUrl(url, { openExternal:true });
}
$("#xyz a").each(function(index) {
$("#xyz a").attr("onclick", "loadURL('" + this.href + "')");
$("#xyz a").attr("style", "text-decoration: underline");
$("#xyz a").removeAttr("href");
});
...and include the following function...
function loadURL(url){
navigator.app.loadUrl(url, { openExternal:true });
}
- 1 Post
- 0 Reply Likes
The following link has a concise description of the problem as well as a fix that makes sense. I used this approach to fix this problem in our app. However, I think that PhoneGap should probably do something like this by default -- just for all links where target="_blank", since that's what web developers expect.
http://www.rigelgroupllc.com/blog/201...
http://www.rigelgroupllc.com/blog/201...
- 9 Posts
- 0 Reply Likes
Sorry, i think , my options are:
-navigator..app . LoadURL (url, {openExternal: true});
-window.open("url",)
-too i can use jquery mobile only, and use "target": "_blank" .....but i i dont know ....
i am provinng "window.open", and i think its work good, but reality is, when i ask view one video, its not work. arggg,
-navigator..app . LoadURL (url, {openExternal: true});
-window.open("url",)
-too i can use jquery mobile only, and use "target": "_blank" .....but i i dont know ....
i am provinng "window.open", and i think its work good, but reality is, when i ask view one video, its not work. arggg,
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers





