Software Archive
Read-only legacy content
17061 Discussions

External Link not works in IOS

Ashok_k_
Beginner
773 Views

Hi Guys,

 

I'm developing an Hybrid app. In IOS the external links are not working with back button. Whenever I click the external link in the app, the link open in a new browser without back button. Also I have close the app and re-launch the app when I click the external link , Here my HTML Code,

 var url = "https://google.com";
    
window.open(url, '_blank', 'location=yes');  

 

Also I have used,

 

window.open(url, '_system', 'location=yes'); 

 

Thanks in advance

0 Kudos
4 Replies
John_H_Intel2
Employee
773 Views

You should check out the Cordova plugin for in app browser. It will open in link in a view, inside your app.

https://github.com/apache/cordova-plugin-inappbrowser

0 Kudos
Ashok_k_
Beginner
773 Views

Hi John,

I'm trying to build Hybrid app  using HTML5 & Angular JS (build IOS)  and I just  added InAppBrowser(0.5.4) through project explorer. I'm using an anchor tag for calling an external link as,

<a  ng-click="openexternallink()">XXXX</a>

and from my controller,

$scope.openexternallink= function(){       
        var url = "http://platform.fatsecret.com";       
        cordova.InAppBrowser.open(url, '_blank', 'location=yes,closebuttoncaption=Done');     
    }

but it does not works. I'm just using Cordova Hybrid build for an IOS, but when I try to work with windows.open method like,

window.open(url, '_system', 'location=yes');

It works but I have close the application to come back to application ( without back button).

 

0 Kudos
John_H_Intel2
Employee
773 Views

See the docs for the inAppBrowser plugin here https://github.com/apache/cordova-plugin-inappbrowser

This function works in my demo app:

// in app browser
    function openBrowser()
    {
        var ref = window.open('http://www.espn.com', '_blank', 'location=yes');
         ref.addEventListener('loadstart', function(event) { alert('start: ' + event.url); });
         ref.addEventListener('loadstop', function(event) { alert('stop: ' + event.url); });
         ref.addEventListener('loaderror', function(event) { alert('error: ' + event.message); });
         ref.addEventListener('exit', function(event) { alert(event.type); });
    }

0 Kudos
PaulF_IntelCorp
Employee
773 Views

Using window.open() with the inAppBrowser is not a reliable tactic, the window.open() function can get redefined after inAppBrowser has commandeered it. Try using the inAppBrowser function calls directly. If you cannot do that, you may need to manually redefine window.open() yourself, as shown in the docs that John points to, above.

See this paragraph, in particular, taken from the inAppBrowser docs:

For backwards compatibility, this plugin also hooks window.open. However, the plugin-installed hook of window.open can have unintended side effects (especially if this plugin is included only as a dependency of another plugin). The hook of window.open will be removed in a future major release.

0 Kudos
Reply