Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3123] Android: webview link with new or blank target (ie "popup") does not open

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-02T10:53:33.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsAndroid
Labelsklist, module_webview, parity, qe-testadded, reported-1.6.0, rplist
ReporterPaul Dowsett
AssigneeNeeraj Gupta
Created2011-04-15T03:37:29.000+0000
Updated2012-04-02T10:53:33.000+0000

Description

Android "APIs 2.2" / Titanium 1.6.0 (11 Feb 2011)

It isn't surprising that this does not work, but I am creating the ticket in the interests of completeness, as the issue has been opened for iOS in ticket #1603 and seems to be confirmed by core devs. Note that the iOS ticket claims that these types of links can be browsed on iOS 4.

Clicking a link in a webview that has a target (new, blank) that would ordinarily open a new window in a standard browser is ignored. The following code demonstrates the behavior:

var win = Ti.UI.createWindow({
    backgroundColor: 'white',
    exitOnClose:true
});

Titanium.UI.setBackgroundColor('#000');

var webView = Ti.UI.createWebView({
    url: "http://www.cnn.com/2010/TECH/social.media/08/12/delta.facebook.ticket.window/index.html",
    top: 0,
    left: 0,
    width: '100%',
    height: '100%'  
});

webView.addEventListener('load',function(e) {
    Ti.API.info("Load event caught with: " + e.url);
});

webView.addEventListener('beforeload',function(e) {
    Ti.API.info("beforeload event caught with: " + e.url);
});

win.add(webView);

win.open();

The built-in browser does recognize the link:

var win = Ti.UI.createWindow({
    backgroundColor: 'white',
    exitOnClose:true
});


Titanium.UI.setBackgroundColor('#000');

win.open();
Ti.Platform.openURL('http://www.cnn.com/2010/TECH/social.media/08/12/delta.facebook.ticket.window/index.html');

Comments

  1. Rick Blalock 2011-04-15

    I've confirmed this as well. target _blank will not open at all in our webView. On iOS it opens in the current webView in which it was clicked.

    HD ticket: http://developer.appcelerator.com/helpdesk/view/76367">http://developer.appcelerator.com/helpdesk/view/76367

  2. Dawson Toth 2011-04-15

    rplist'd, klist'd, added TBS Milestone

  3. Wilson Luu 2011-11-01

    Bug is still valid, occurs in: TiMOB sdk version: 1.8.0.v20111031173855 Studio version: 1.0.6.201110251616 OS version: Mac OS X Lion Devices tested on: Droid 2.2.2, Galaxy Tab 3.1
  4. Devang Gandhi 2012-01-30

    Another case here: http://support-admin.appcelerator.com/display/APP-871916 The web view is loaded on iOS, but not on android.
  5. Daniel Urstoeger 2012-01-31

    you can temporary fix it like this:
       webview.addEventListener('load',function(e)
       {
        var content = webview.evalJS("document.body.innerHTML = document.body.innerHTML.replace(/target=\"_blank\"/gi,'');");
       });
       
  6. Wilson Luu 2012-03-21

    Reopening bug. Still persists on: SDK build: 2.0.0.v20120321071752 Runtime: v8, rhino Titanium Studio, build: 2.0.0.201203202130 Device: Droid 1 (2.2.3) Note: * Above code still works on iOS * I noticed some interesting logs in logcat. But, not sure if it's related:
       I/TiWebChromeClient.console( 1823): (main) [1303,48838] Uncaught illegal access (1:https://s-static.ak.facebook.com/xd_localstorage/v2)
       I/TiAPI   ( 1823): Load event caught with: http://www.cnn.com/2010/TECH/social.media/08/12/delta.facebook.ticket.window/index.html
       I/TiWebChromeClient.console( 1823): (main) [1167,50005] Uncaught illegal access (1:https://s-static.ak.facebook.com/xd_localstorage/v2)
       
  7. Wilson Luu 2012-03-22

  8. Michael Pettiford 2012-04-02

    Reopening/closing to add/remove labels

JSON Source