Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-12425

Android: WebView: the "load" event is fired twice if setHtml() is called before the window opens

    Details

      Description

      Steps to reproduce:
      1. Run the code attached below.
      2. Two alerts show which means the "load" event is fired twice. Expected behavior: load should be only fired once.
      Note:
      i) if commenting out webview.setHtml("xxx") but use webview.html="xxx", the "load" event will be only fired once.
      ii) if running on Galaxy Nexus (4.0.4), a warning shows in the console, like

      W/webview ( 2264): java.lang.Throwable: Warning: A WebView method was called on thread 'KrollRuntimeThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.

      var _window = Ti.UI.createWindow({
      	backgroundColor : '#000'
      })
       
      var webview = Ti.UI.createWebView({
      	top : 0,
      	height : 200
      });
       
      webview.setHtml('<html><body>test</body></html>');
      //webview.html = '<html><body>test</body></html>';
       
      webview.addEventListener('load', function() {
      	alert('The webview is loaded!');
      });
       
      _window.add(webview);
      _window.open(); 
      

        Attachments

          Activity

            People

            • Assignee:
              pwang Ping Wang
              Reporter:
              pwang Ping Wang
              Reviewer:
              Hieu Pham
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-15430
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration