I can't open external links within Phonegap Build (Using HTML5)

  • 1
  • Problem
  • Updated 4 years ago
Hi!

I've tried hundreds of ways how to open external Links with HTML5 and Phonegap Build ... It seems as if somethin is missing!

I've included this one:
script type="text/javascript" src="cordova.js" /script

And I tried this kind of links:
a href="#" onclick="window.open('http://www.nhl.com', '_blank', 'location=yes');">_blank /a
a href="#" onclick="window.open('http://www.nhl.com', '_system', 'location=yes');">_system /a
a href="#" onclick="window.open'http://www.nhl.com', '_self', 'location=yes');">_self /a

a href="#" onclick="openUrlInBlankBrowser();" target="_system" >Link /a

and here is the function to it:
function openUrlInBlankBrowser()
{
navigator.app.loadUrl('http://www.google.com', { openExternal:true } );
}

Any Ideas? ... I think it can't be that much??

Thanks in advance,
mat
Photo of Mathias Spanring

Mathias Spanring

  • 3 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. Do you use the inAppBrowser plugin?
2. How did you whitelist the external domain?
Photo of Mathias Spanring

Mathias Spanring

  • 3 Posts
  • 0 Reply Likes
1. no, I don't use the AppBrowser plugin ... it's just plain html
2. I wrote this part in the config.xml
access origin="*" /
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. I would recommend using the inAppBrowser plugin
(your syntax of window.open() appears to be based on an old version of that plugin, so I assume you have copied and pasted that code without being aware what it takes to execute that code)
2. That access rule is only sufficient if you build with an old version of PGB (which is deprecated). You should use the Whitelist plugin and follow its docs.
Photo of Mathias Spanring

Mathias Spanring

  • 3 Posts
  • 0 Reply Likes
Thank you very much ... that fixed my problem!

So I:
1. use the inAppBrowser Plugin and
2. the Whitelist plugin

and I also made the mistake, that I didn't use a Phonegap Version within
my config.xml file ;) (which was necessary for the Plugins to work)