Phonegap - How to Open External Link Inside The App

PhoneGap Build: how to open external url in device browser on Android?

It's not the answer when you want to keep using PhoneGap Build, but I solved the problem by setting up a development environment for Cordova (PhoneGap) on my machine and compiling the app locally. In Cordova 2.5.0 window.open('http://www.myurl.nl', '_system'); works perfect, it will open the link in the system's browser.

So my advice is to stop using PhoneGap Build and start compiling your app locally. Here's how to set up your development environment for Cordova >>

Open external links in Phonegap Build App (iOS/Android)

The solution for my problem was include phonegap.js file to my <head> in all the pages where I will use the InAppBrowser: <script src="phonegap.js"></script>

I'm gonna explain a little, why this solution in first time doesn't seem logic to me (and maybe you too), but then I tried and it works.

This is what Phonegap in his plugin documentation section says:

"If a plugin utilizes the js-module element to direct cordova to load the plugin javascripts, then no <script> references will be necessary to load a plugin. This is the case for the core cordova plugins"

InAppBrowser is a core cordova plugin. But for some strange reason don't work until you include the phonegap.js file (at least in 0.3.3 version).

NOTE: I found a bug. Some people says that you have to include 3 files: phonegap.js, cordova.js and cordova_plugins.js. But when I include this 3 files my app works fine in iOS 7, but in iOS 6 ignore the use of the plugin (Using: Cordova 3.3.0 + Phonegap Build + InAppBrowser 0.3.3).

Cordova 6 : how to stay in app when opening an external url?

Using the InAppBrowser Plugin you should be able to do:

cordova.InAppBrowser.open('http://apache.org', '_self', 'location=yes');

Notice the _self target in the second parameter. This will open the site in the app's WebView.



Related Topics



Leave a reply



Submit