Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8113] Android: Ti.UI.WebView doesn't seem to load pages that try to open a new window

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-17T11:28:30.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.1.0, Sprint 2012-08
ComponentsAndroid
LabelsSupportTeam, api, module_webview, qe-testadded
ReporterJunaid Younus
AssigneeJosh Roesslein
Created2012-03-20T11:25:42.000+0000
Updated2014-08-21T21:21:11.000+0000

Description

*Code* * app.js
var win = Ti.UI.createWindow();

var webview = Titanium.UI.createWebView({ 
	url: 'index.html'
});

win.add(webview);

win.open();
* index.html
<a href="http://www.google.com" target="_blank">Click to load Google in a new window.</a>
<br></br>
<a href="http://www.google.com">Click to load Google in the same window.</a>
*Expected behavior* When you click on either of the two links, it should load up Google. *Actual behavior* What actually happens, is that the first link doesn't seem to do anything, only the second one seems to work. *Notes* -Only tested on a HTC Sensation and Samsung Galaxy S2, both giving me the same result. -Same result, whether I use the Rhino or V8 engine. -When testing the same code on the iOS simulator, both links seem to work fine. -The issue is 'target="_blank"' without this, it seems to work fine. -HD ticket: http://support-admin.appcelerator.com/display/APP-257637

Comments

  1. Josh Roesslein 2012-04-12

    Submitted PR [#1996](https://github.com/appcelerator/titanium_mobile/pull/1996) to resolve issue. This fixes a new, currently undocumented API onCreateWindow callback. Also it adds default behavior if this callback is not set which just opens a new activity window containing the new WebView instance.

    WebView.onCreateWindow

       var win = Ti.UI.createWindow();
       var webview = Ti.UI.createWebView({ url:'index.html' });
       
       webview.onCreateWindow = function(e) {
           if (!e.isUserGesture) {
               return null;
           }
        
           var webWin = Ti.UI.createWindow({
               fullscreen: false
           });
           var newWebView = Ti.UI.createWebView();
           webWin.add(newWebView);
           webWin.open();
        
           return newWebView;
       };
        
       win.add(webview);
        
       win.open();
       
    Use the same index.html in this ticket's description. NOTE: onCreateWindow is not currently public and shouldn't be used yet. This test case is purely for testing purposes.
  2. Bill Dawson 2012-04-16

    Re-opening because it looks like the change doesn't work in Rhino: http://pastie.org/3799021
  3. Josh Roesslein 2012-04-16

    [PR #2013](https://github.com/appcelerator/titanium_mobile/pull/2013) sent to resolve Rhino issue.
  4. Payminder Singh 2012-06-23

    Titanium Studio: 2.1.0.201206221045 Mobile SDK: 2.1.0.v20120622174154 OS: X Lion Device: Samsung Galaxy Fixed Both hyperlinks are working and providing the expected result by opening the Google.com

JSON Source