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

Android: evalJS for javascript functions in webview results in a crash

    Details

      Description

      Evaluating a javascript function inside an html results in a crash. works fine on iOS
      Step1: copy the below code to app.js

      var win = Ti.UI.createWindow({ backgroundColor: '#cccccc' });
      	    
      var webView = Ti.UI.createWebView({ width: 300, height: 200, top: 0, left: 0,backgroundColor: 'white', 
      url:'test.html'
      });  	
      win.add(webView);
       
      webView.addEventListener('load', function(){
      	
      	Ti.API.debug('webivew loaded');
      //	 var title = webView.evalJS("document.title");   // this works fine!
      //	Ti.API.debug(title);
      	var foo_return = webView.evalJS("foo('Hi')");   
      	Ti.API.debug(foo_return);
       
       
      });
       
      win.open();
      

      Step2: Copy the below code to 'test.html' under the resources.

      <!doctype html>
      <html>
      	<head>
      		<title>Test Webview Page</title>
      		
      </head>
      	<body><h1>My hovercraft is full of eels.</h1>
      	<script type="text/javascript">
      			function foo(msg) { alert(msg); };
      		</script>
      		
      	</body>
      </html>
      

      Step3: Crash log from ddms is attached.

        Attachments

          Activity

            People

            • Assignee:
              billdawson Bill Dawson
              Reporter:
              anagesh Anirudh Nagesh
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration