I am updating a PhoneGap app and somehow external links are now broken. Depending on how I tweak the code, it goes between only opening links in the InAppBrowser, which does not provide a way of returning to the application, or doing nothing.
I have the following in my config file:
<access origin="*" />
<preference name="phonegap-version" value="3.4.0" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="permissions" value="none"/>
<gap:plugin name="org.apache.cordova.inappbrowser" version="0.2.4"
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
<gap:plugin name="com.phonegap.plugin.statusbar" version="1.1.0" />
<preference name="StatusBarOverlaysWebView" value="false" />
I have the following function in my main Javascript file, which is referenced by the index page along with phonegap.js and cordova.js:
setUpExternalUrls = function () {
$("a.url").click(function (e) {
// Prevent default navigation to the link and stop event bubbling
e.preventDefault();
var href = e.data("href") || e.attr("href");
cordova.exec(null, null, "InAppBrowser", "open", [href, "_system"]);
});
},
I also tried the above with
window.open(href, "_system");
rather than cordova.exec.
The call to it is located here:
onDeviceReady = function () {
setUpMaps();
$(".language-select").on("change", selectChangedHandler);
setUpTranslations();
$(document).trigger("pagebeforeshow");
setUpExternalUrls();
setUpBackButtons();
if (parseFloat(window.device.version) >= 7.0) {
document.body.style.marginTop = "20px";
}
},
Here is an example URL from the index page:
I have read through just about every topic I can find on this issue and nothing seems to work.