Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16650] BlackBerry: Calling webview.evalJS works, but does NOT return a value

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2014-04-02T22:19:44.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsBlackBerry
LabelssupportTeam
ReporterDavide Cassenti
AssigneePedro Enrique
Created2014-03-20T17:06:52.000+0000
Updated2017-03-13T20:59:40.000+0000

Description

Problem description

When calling evalJS on a webview in BB10, the javascript is invoked, but there is no return value.

Code sample

Just use this code:
var win = Ti.UI.createWindow({
    backgroundColor:'white'
});
 
var webview = Ti.UI.createWebView({
    url : 'http://www.example.com'
});
 
 
webview.addEventListener('load', function() {
    alert(webview.evalJS('window.location.href'));
});
 
win.add(webview);
win.open();

Note

evalJS works. Replace the alert with this to verify:
webview.evalJS('alert(window.location.href)');

Comments

  1. Pedro Enrique 2014-04-01

    The API will be the following. BB's evalJS implementation is async
       webview.evalJS('window.location.href', function(){
       	alert(e.result);
       });
       
  2. Pedro Enrique 2014-04-01

    PR Pending https://github.com/appcelerator/titanium_mobile_blackberry/pull/210
  3. Lee Morris 2017-03-13

    Closing ticket as fixed.

JSON Source