Hi!, I've read a number of posts about opening up a link in safari. Some are for old versions of phonegap, while others I am not sure.
So, what's the working solution for the current versions?
Thanks!
Igor
So, what's the working solution for the current versions?
Thanks!
Igor
- 27 Posts
- 0 Reply Likes
Posted 7 years ago
- 27 Posts
- 0 Reply Likes
And by the way. I'd like to get the solution which will also waork for android (if it's possible), so that it would open the link in chrome on android too.
- 1206 Posts
- 42 Reply Likes
Hi Igor,
Use InAppBrowser with target equal to
'self' (webview), 'blank' (InAppBrowser), '_system' (system web browser
stay-in-webview with values true or false example: <preference
name="stay-in-webview" value="true" />
if
set to true, all links (even with target set to blank) will open in the app's
webview
only use this preference if you want pages
from your server to take over your entire app
default is false
For more information
https://build.phonegap.com/docs/config-xml
Thanks
Hyginus
Use InAppBrowser with target equal to
'self' (webview), 'blank' (InAppBrowser), '_system' (system web browser
stay-in-webview with values true or false example: <preference
name="stay-in-webview" value="true" />
if
set to true, all links (even with target set to blank) will open in the app's
webview
only use this preference if you want pages
from your server to take over your entire app
default is false
For more information
https://build.phonegap.com/docs/config-xml
Thanks
Hyginus
- 27 Posts
- 0 Reply Likes
Hi, thanks for the reply.
I fixed the config.xml, set stay in web view to false. So how shall my links look now?
Thanks in advance.
Igor
I fixed the config.xml, set stay in web view to false. So how shall my links look now?
Thanks in advance.
Igor
- 27 Posts
- 0 Reply Likes
Hi again.
I'm not so good at coding, so I'd like to get as detailed as possible way to solve the problem, step-by-step. I hope somebody will be able to help me.
Thanks on advance.
Igor.
I'm not so good at coding, so I'd like to get as detailed as possible way to solve the problem, step-by-step. I hope somebody will be able to help me.
Thanks on advance.
Igor.
- 1206 Posts
- 42 Reply Likes
Hi Igor,
For more example and test code can be found here.
http://docs.phonegap.com/en/2.9.0/cor...
Thanks
Hyginus
For more example and test code can be found here.
http://docs.phonegap.com/en/2.9.0/cor...
Thanks
Hyginus
- 27 Posts
- 0 Reply Likes
Still can't make it work.
This is my example link
And when i click it - nothing happens, i mean it seems to attempt to load it but nothing's going well so far. And the previous page stops respondong too.
How shall my link look to correctly open itself in safari?
This is my example link
<li data-icon="toprated"><a href="#" onclick="window.open('http://db.tt/DDFAqU6R', '_system');">sampletext</a>
And when i click it - nothing happens, i mean it seems to attempt to load it but nothing's going well so far. And the previous page stops respondong too.
How shall my link look to correctly open itself in safari?
- 255 Posts
- 0 Reply Likes
navigator.app.loadUrl(url, { openExternal:true } );
Try this:
Try this:
<li data-icon="toprated">
<a href="#" onclick="navigator.app.loadUrl('http://db.tt/DDFAqU6R', { openExternal:true } );">sampletext</a>
- 27 Posts
- 0 Reply Likes
- 27 Posts
- 0 Reply Likes
- 1206 Posts
- 42 Reply Likes
- 27 Posts
- 0 Reply Likes
- 157 Posts
- 5 Reply Likes
Solved using appinbrowserplugin and
window.open(targetURL, '_system', 'location=yes')
window.open(targetURL, '_system', 'location=yes')
- 27 Posts
- 0 Reply Likes
Is this solution suitable for ios? Or android only?
- 6 Posts
- 0 Reply Likes
I have come to find out that when I build my Phonegap app in 2.9.0, my links open in the system broswer (Safari for iOS). But when I build my app in 3.0.0+ it won't work. All links are then opened in the app webview. How could I go about fixing this and what is changing between builds?
ryan, Developer
- 1538 Posts
- 132 Reply Likes
Austin in 3.0.0+ make sure you are including the InAppBrowser plugin:
https://build.phonegap.com/plugins/233
In 3.0.0 all core APIs were split into plugins.
<gap:plugin name="com.phonegap.plugins.inappbrowser" />
https://build.phonegap.com/plugins/233
In 3.0.0 all core APIs were split into plugins.
- 11 Posts
- 0 Reply Likes
plugin unsupported: com.phonegap.plugins.inappbrowser
- 11 Posts
- 0 Reply Likes
whereas this doesn't have the error: gap:plugin name="org.apache.cordova.inappbrowser"
- 27 Posts
- 0 Reply Likes
"Solved using appinbrowserplugin and
window.open(targetURL, '_system', 'location=yes')"
I'm not so pro in this, can anyone tell me how shall my code look like, assuming this solution works.
This is how it looks now
And i've got the plugin enabled in config.xml
window.open(targetURL, '_system', 'location=yes')"
I'm not so pro in this, can anyone tell me how shall my code look like, assuming this solution works.
This is how it looks now
<ul>
<li data-icon="toprated">
<a href="#" onclick="window.open(http://db.tt/DDFAqU6R, '_system', 'location=yes')">some text</a>
</ul>
And i've got the plugin enabled in config.xml
<gap:plugin name="org.apache.cordova.inappbrowser" />
Eddy Verbruggen, Champion
- 375 Posts
- 86 Reply Likes
Maybe it's nothing, but there are no quotes around your url:
should be:
window.open(http://db.tt/DDFAqU6R,
should be:
window.open('http://db.tt/DDFAqU6R',- 27 Posts
- 0 Reply Likes
I also tried pasting the example code
It gives me blank screen
<!DOCTYPE html>
<html>
<head>
<title>window.open Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
// external url
var ref = window.open(encodeURI('http://apache.org'), '_blank', 'location=yes');
// relative document
ref = window.open('next.html', '_self');
}
</script>
</head>
<body>
</body>
</html>
It gives me blank screen
- 4116 Posts
- 192 Reply Likes
Hi Igor,
Do you have your access permissions set in config.xml?
Replace cordova.js with phonegap.js as well.
Can I know the list of plugins you have installed with this?
Also do help provide app id for this.
Thanks.
Ismael
Do you have your access permissions set in config.xml?
Replace cordova.js with phonegap.js as well.
Can I know the list of plugins you have installed with this?
Also do help provide app id for this.
Thanks.
Ismael
- 27 Posts
- 0 Reply Likes
Yes, all external connections are allowed.
Will try when back home.
I have only inappbrowser installed.
Could you, please give me your skype or other IM, so that it would be easier to fix.
Thanks.
Will try when back home.
I have only inappbrowser installed.
Could you, please give me your skype or other IM, so that it would be easier to fix.
Thanks.
- 11 Posts
- 0 Reply Likes
arrrgggg... having the exact same problem.. something so simple shouldn't be so hard.
Using build.phonegap.com
From my config.xml file:
preference name="phonegap-version" value="3.0.0"
gap:plugin name="org.apache.cordova.inappbrowser"
preference name="stay-in-webview" value="false"
inappbrowser is the only plugin included
---------------------------
javascript code that gets executed when a user taps a link:
function open_external_link(url) {
window.open(url,"_system","location=yes");
}
result:
url opens up in webview, not in external browser.
I've worked at this for hours and hours trying different things... at whits end.
app id: 591898
Cheers,
Scott
Using build.phonegap.com
From my config.xml file:
preference name="phonegap-version" value="3.0.0"
gap:plugin name="org.apache.cordova.inappbrowser"
preference name="stay-in-webview" value="false"
inappbrowser is the only plugin included
---------------------------
javascript code that gets executed when a user taps a link:
function open_external_link(url) {
window.open(url,"_system","location=yes");
}
result:
url opens up in webview, not in external browser.
I've worked at this for hours and hours trying different things... at whits end.
app id: 591898
Cheers,
Scott
- 1206 Posts
- 42 Reply Likes
Hi Scott,
Can you try (url,"_blank......
Also don't forget to whitelist your external url config.xml
Thanks
Hyginus
Can you try (url,"_blank......
Also don't forget to whitelist your external url config.xml
Thanks
Hyginus
- 11 Posts
- 0 Reply Likes
@Hyginus,
_blank does not work - the documentation, as it was pointed out above in the replies, says that _system will work in an external browser, whereas _blank, also documented, indicates a new top level window in the same browser (which is exactly what it does - yay). Whereas _system is currently working exactly like _blank.
The whitelist is not an option as the main links are supplied ad-hoc by my clients, and there are thousands.
Could someone actually look into why this is not working and stop with the guessing. Looking at the posts above that's all that has taken place and many of the "suggestions" are counter to each other, some are flat out wrong - indicating that people that should be in the know - aren't.
It's beginning to look like asking Adobe about their own product is going to be fruitless as this post started 3 months ago and apparently has not been resolved. I think Igor has been more than patient waiting for someone to help him out with this (3 months) and I'm just getting started.
Scott
_blank does not work - the documentation, as it was pointed out above in the replies, says that _system will work in an external browser, whereas _blank, also documented, indicates a new top level window in the same browser (which is exactly what it does - yay). Whereas _system is currently working exactly like _blank.
The whitelist is not an option as the main links are supplied ad-hoc by my clients, and there are thousands.
Could someone actually look into why this is not working and stop with the guessing. Looking at the posts above that's all that has taken place and many of the "suggestions" are counter to each other, some are flat out wrong - indicating that people that should be in the know - aren't.
It's beginning to look like asking Adobe about their own product is going to be fruitless as this post started 3 months ago and apparently has not been resolved. I think Igor has been more than patient waiting for someone to help him out with this (3 months) and I'm just getting started.
Scott
This conversation is no longer open for comments or replies.
This conversation is no longer open for comments or replies.
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers





