This is a migrated thread and some comments may be shown as answers.

InAppBrowser plugin behaving differently: window.open vs. _blank

4 Answers 822 Views
AppBuilder Windows client
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim S.
Top achievements
Rank 1
Tim S. asked on 04 Jan 2014, 10:45 PM
Hi 

What Cordova says about the InAppBrowser plugin:
" This plugin provides a web browser view that displays when calling  window.open(), or when opening a link formed as <a target="_blank">. " (source)

According to Cordova's documentation on the InAppBrowser I can do the following:

function myFunction() {
    window.open('http://apache.org', '_blank', 'location=yes');
};

// on a html element like <a href="#" onclick="myFunction()">Link</a>

...which (how I interpret it) should have the same result as:

<a href="http://apache.org" target="_blank">

...however, with the last html only approach it does not give me the same result as in the first javascript approach, namely

  1. Javascript approach: Opens url in InAppBrowser with toolbar and 'Done' button (i.e. all the default behaviour).
  2. HTML approach: Opens url in fullscreen 'iframe-like' window which allows scrolling, however no toolbar and 'Done' button
Someone knows what is actually happening and why it is different? I desire to understand so I can approach my issue in a better way (which is that I prefer to use the html approach with the default InAppBrowser behaviour).

I'm using Cordova 3.2.0 in Icenium Graphite for an iOS iPad app.
Thx

4 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 08 Jan 2014, 03:16 PM
Hi Tim,

Both are different, so that is why your assumption is wrong. The HTML approach would open the link in the device's built-in browser, and as the browser is basically another app, there is no reference to the app it came from or a way to get back to it. That is one of the goals of the InAppBrowser approach, which opens in the context of your app and has a button so that you could easily get back to the app.

Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
0
Tim S.
Top achievements
Rank 1
answered on 08 Jan 2014, 09:02 PM
Thanks Steve, now it makes sense.
0
Stroika
Top achievements
Rank 1
answered on 27 Mar 2014, 05:52 PM
Nice Tim,
but the done button in  InAppBrowser return me to the root (home//index) not to the last view,please tell me if there is perfect solution to make done button return me to the last view  

Thanks
Omar
0
Zdravko
Telerik team
answered on 01 Apr 2014, 08:15 AM
Hi Omar,

In order to achieve your goal I will suggest using something like the code below:

function myFunction() {
            var location= window.location.href;
            iab = window.open('http://apache.org', '_blank', 'location=yes');
            iab.addEventListener('exit', function () {
                window.location.href=location;
            });
        };

You can find more information about InAppBrowser events here.
Thanks.

Regards,
Zdravko
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

 
Tags
AppBuilder Windows client
Asked by
Tim S.
Top achievements
Rank 1
Answers by
Steve
Telerik team
Tim S.
Top achievements
Rank 1
Stroika
Top achievements
Rank 1
Zdravko
Telerik team
Share this question
or