InAppBrowser will not open external links in System browser on iOS

246 views
Skip to first unread message

Ryan Acumen

unread,
Aug 26, 2014, 2:29:57 PM8/26/14
to phon...@googlegroups.com
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:
<a class="url" href="http://mpdc.dc.gov/page/sex-assault-unit">...</a>

I have read through just about every topic I can find on this issue and nothing seems to work.

Keng Wai Chiah

unread,
Aug 27, 2014, 11:35:59 AM8/27/14
to phon...@googlegroups.com
quick one, have you try
window.open("http://bondwith.me/", "_blank", "location=yes");

Ryan Acumen

unread,
Aug 28, 2014, 11:46:59 AM8/28/14
to phon...@googlegroups.com
The problem was, contrary to the answer on almost every thread about this on the internet, including cordova.js.  It should not be included.  If anyone else has this problem, try commenting out this script include on your HTML page(s)!
Reply all
Reply to author
Forward
0 new messages