Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16376] Android: Expose Webview's configuration flags in Android for fine tuning

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusIn Review
ResolutionUnresolved
Affected Version/sRelease 3.2.0
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, exalture
ReporterMauro Parra-Miranda
AssigneeUnknown
Created2014-02-05T00:51:55.000+0000
Updated2018-02-28T20:03:50.000+0000

Description

Problem Description

Currently, the Android implementation of Titanium Mobile API, will hardcode the flags for the webview behavior like:
settings.setSupportMultipleWindows(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
The user wants to be able to control those from within the JS level, in order to accomplish things like: "I need to prevent the webview to open another window"

Q&A reference

http://developer.appcelerator.com/question/162213/webview-prevent-target-blank-from-opening-in-new-window--android-settings

Comments

  1. Ron Wondaal 2014-07-08

    Any news on this ticket? I too need the ability of running android web views in one window. Would be great if it could be included in the next release.
  2. Andrew McElroy 2014-07-08

    would you all accept a pull request for this one. This is truly a trivial change. I would actually change the following lines (188- 194) to accept a value but leave these current values if none are set. The file in question is android/modules/ui/src/ti/modules/titanium/ui/widget/webview/TiUIWebView again (lines 188-194): settings.setUseWideViewPort(true); settings.setJavaScriptEnabled(true); settings.setSupportMultipleWindows(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLoadsImagesAutomatically(true); settings.setDomStorageEnabled(true); // Required by some sites such as Twitter. This is in our iOS WebView too. @Ron I don't work for Appcelerator and I give no warranty to what I'm about to say, but if you desperately need this in a pinch then build an android module that extracts this functionality out. If someone can point me to a good way to method intercept / swizzle, then I'd hazard a module for android.
  3. Ron Wondaal 2014-07-09

    Hi Andrew, I actually always wondered what exactly a pull request is. I believe it is an outside contribution to the SDK right? If you could make it so I would gladly accept it. About creating a module for it, I thought about it, but I'm not so into java. OBJ-C no problem but I switched to Titanium to avoid having to code in java. I think all it takes is a function that accepts a webview, sets the values and returns the web view back to titanium. I'll see if I could cook that up somewhere in the next days.
  4. Ron Wondaal 2014-07-15

    Hi Andrew, Would it be possible for you to still create this pull request? I would really have no idea where to start!
  5. Sunila 2014-09-20

    supportMultipleWindows in webview is exposed. I think to disable opening new windows, one can attach a handler to onCreateWindow and return null, something like webview.onCreateWindow = function() { return null;} https://github.com/appcelerator/titanium_mobile/pull/6140
  6. Lev 2014-10-08

    Preventing opening new windows works ok if return null. If I want to open popup contents in the same webview (like iOS does), so I do like this:
    webView.onCreateWindow = function(e) {
               return webView;
       };
    But it crashes the app. Also if I try to run the snippet from http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.WebView-property-onCreateWindow, I get a blank webview in "New page" tab and in console manymany logs like this:
    [INFO] I/TiWebChromeClient.console: (main) [196,277988] Uncaught ReferenceError: TiApp is not defined (1:null)

JSON Source