disable inappbrowser

1,197 views
Skip to first unread message

Michael SBCERA

unread,
Mar 26, 2013, 7:00:15 PM3/26/13
to phon...@googlegroups.com
How can I disable the InAppBrowser? Childbrowser worked fine and now all my links are hijacked by this plugin and opened in a browser with an address bar. I also use zRSSfeed for a displaying an RSS feed and I can't access the links.

Thanks

Michael SBCERA

unread,
Mar 26, 2013, 7:00:53 PM3/26/13
to phon...@googlegroups.com
Android

Shazron

unread,
Mar 26, 2013, 7:09:00 PM3/26/13
to phonegap
Cordova clobbers window.open, so you would have to save the old reference before this clobber.

1. Save window.open before loading cordova.js
2. Load cordova.js
3. On deviceready, restore window.open


Android
--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael SBCERA

unread,
Mar 26, 2013, 7:50:33 PM3/26/13
to phon...@googlegroups.com
So I basically can't use CB anymore?

Shazron

unread,
Mar 26, 2013, 7:57:58 PM3/26/13
to phonegap
Did I say that? read the steps again. cordova.js is still loaded, you're just overriding Cordova's window.open

Shazron

unread,
Mar 26, 2013, 8:04:11 PM3/26/13
to phonegap
Sorry misread, my apologies. CB is just a plugin, independent of Cordova core.

Michael SBCERA

unread,
Mar 26, 2013, 8:08:34 PM3/26/13
to phon...@googlegroups.com
I guess the issue is that window.plugins.childBrowser.showWebPage no longer opens CB in Cordova-2.3.0. I just get native browser outside of app.

Shazron

unread,
Mar 27, 2013, 12:51:56 AM3/27/13
to phonegap
That's strange - if CB doesn't work for 2.3.0 then the CB plugin on PG Build won't work as well

Michael SBCERA

unread,
Mar 27, 2013, 11:03:58 AM3/27/13
to phon...@googlegroups.com
Let me review my code to see if I'm missing something that is preventing CB.

Michael SBCERA

unread,
Mar 27, 2013, 11:59:36 AM3/27/13
to phon...@googlegroups.com
Sorry Shazron, CB is working on links where I can access the onclick event. The challenge is with the zRSSfeed plugin where I don't have access to the link. When I click on one of the feeds, I get this log:

03-27 15:14:49.655: D/DroidGap(331): onMessage(onPageStarted,url)
03-27 15:14:49.935: D/Cordova(331): onPageFinished(url)
03-27 15:14:49.935: D/DroidGap(331): onMessage(onNativeReady,null)
03-27 15:14:49.935: D/DroidGap(331): onMessage(onPageFinished,url)

Is this the inAppBrowser opening the link? The issue I am having is that when the same link is opened in CB it is filling browser window 100%. When that link is opened with inAppBrowser(above log) it opens as if it is zoomed in. The web page is too large and can not be zoomed out.

Michael SBCERA

unread,
Mar 27, 2013, 7:18:01 PM3/27/13
to phon...@googlegroups.com
From someone else on StackOverflow. Is this really a solution?

I'm using the cordova InAppBrowser to display content from an external site. When I open the browser on an iPhone, the zoom level of the InAppBrowser contents matches that of the rest of my app. When I navigate to the same place in my Android device, the InAppBrowser content appears zoomed way out and is very small and is difficult to read.

Does anyone know of a way to set or adjust the zoom level or viewport of the InAppBrowser for the Android device?

Note: I have some control over the styling of the content that is displayed in the InAppBrowser, but not the html or javascript for that site.



0 down vote accepted

I found a way to change the android InAppBrowser viewport to be consistent with that of the iOS InAppBrowser. It requires modifying the cordova source code, but it's actually pretty easy to do... just need to change one line of code.

Here are some step-by-step instructions:

  1. Download the cordova source code: "git clone https://github.com/apache/cordova-android.git"
  2. Download the commons codec lib: http://ftp.carnet.hr/misc/apache//commons/codec/binaries/commons-codec-1.7-bin.zip
  3. Open Android Developer Tools
  4. Import the cordova project into your workspace (File > Import... > Existing Projects into Workspace)
  5. Create a "libs" directory and copy the downloaded commons-codec-1.7.jar file into it.
  6. Add a "gen" folder to the project (required by the .classpath file, but not included in the git download since git doesn't allow empty folders)
  7. Go to Project > Build All. The project should build without errors.
  8. Open InAppBrowser.java and search for "inAppWebView.getSettings().setUseWideViewPort(true);" (line 458 in the cordova version I downloaded).
  9. Change "true" to "false" in that line.
  10. Build the project again.
  11. Copy the bin/cordova.jar file into whatever project you are using cordova in.

That will change the viewport to be consistent with the iOS InAppBrowser. If you prefer the wider viewport, but still want consistency among Android/iOS, you could probably do something similar in the cordova-ios source code to change iOS to use the wider viewport (but I haven't looked into that).

I got some of the information regarding obtaining the cordova source code and building the project from this google group: https://groups.google.com/forum/?fromgroups=#!topic/phonegap/mUcBcjPISgg



Michael SBCERA

unread,
Mar 27, 2013, 7:34:41 PM3/27/13
to phon...@googlegroups.com
So oddly this zoomed in thing does not happen if I use <a href="#" onclick="window.open('url','_blank');">

It looks like it is only happening with _self links. I don't have access to those RSS links so I have no way to change from _self


Michael SBCERA

unread,
Mar 27, 2013, 7:50:48 PM3/27/13
to phon...@googlegroups.com
Sorry for having my process in this forum. With the zRSSfeed plugin, I am able to change the link target to _blank but it has no effect on the zoomed in view. It is as if cordova ignores and just defaults to _self.

Simon MacDonald

unread,
Mar 28, 2013, 8:35:36 AM3/28/13
to phonegap
The rules of the InAppBrowser:

_self - opens in the Cordova WebView if url is in the white-list, else
it opens in the InAppBrowser
_blank - always open in the InAppBrowser
_system - always open in the system web browser

So if you shouldn't ever be seeing it opening in the browser if your
specify '_blank'. What does the link look like you are trying to open?


Simon Mac Donald
http://hi.im/simonmacdonald

Michael SBCERA

unread,
Mar 28, 2013, 11:53:10 AM3/28/13
to phon...@googlegroups.com
So I tried with both a .html link and a .pdf link. Behavior is the same. _self opens zoomed way in, _blank opens normal 100% of window.

Simon MacDonald

unread,
Mar 28, 2013, 11:57:59 AM3/28/13
to phonegap
I meant show me the exact html...
Simon Mac Donald
http://hi.im/simonmacdonald


Michael SBCERA

unread,
Mar 28, 2013, 12:43:16 PM3/28/13
to phon...@googlegroups.com
<a href="#" onclick="window.open('http://www.sbcera.org','_blank');">

<a href="#" onclick="window.open('http://www.sbcera.org','_self');">

<a href="#" onclick="window.open('http://www.sbcera.org/Newsletter','_blank');">

<a href="#" onclick="window.open('http://www.sbcera.org/Newsletter','_self');">

Michael SBCERA

unread,
Mar 28, 2013, 12:56:37 PM3/28/13
to phon...@googlegroups.com
It does same thing with LA Times.com

Michael SBCERA

unread,
Apr 1, 2013, 12:40:46 PM4/1/13
to phon...@googlegroups.com
So is this an InAppBrowser bug?

Shazron

unread,
Apr 1, 2013, 3:03:18 PM4/1/13
to phonegap
No - try the same thing with a <button> as a comparison. If you use an anchor tag you have to suppress the default behaviour. https://gist.github.com/shazron/4694032


On Mon, Apr 1, 2013 at 9:40 AM, Michael SBCERA <sbc...@gmail.com> wrote:
So is this an InAppBrowser bug?

Michael SBCERA

unread,
Apr 1, 2013, 4:30:40 PM4/1/13
to phon...@googlegroups.com
But why is the page zoomed so far in? That is primarily the issue.


You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/eVr-SFdVA7I/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to phonegap+u...@googlegroups.com.

Michael SBCERA

unread,
Apr 1, 2013, 5:15:27 PM4/1/13
to phon...@googlegroups.com
It doesn't matter if I use <button> or <a>, I get the same exact results. _self is zoomed way in with no location and large, _blank fits 100% and has location with done button. This is for both <button> and <a> link. It seems like it is Cordova webview that is zoomed in. When I remove * from my whitelist in AndroidManifest.xml my links are launched in InAppBrowser at the right view. This seems like a terrible solution. Also it seems with zRSSFeed that my option of _blank has no affect on the links in my feed now.

Michael SBCERA

unread,
Apr 2, 2013, 7:05:13 PM4/2/13
to phon...@googlegroups.com
So is my answer going to be remove the url from white list to force inappbrowser?


Reply all
Reply to author
Forward
0 new messages