Details
Description
When executing some javascript via evalJS on a WebView nothing happens and this error appears in the console:
[INFO] : I/TiWebChromeClient.console: (main) [255,24655] Uncaught SyntaxError: Unexpected token for (1:file:///data/data/com.ortec.synergy/cache/86/platform_article_135660018/article.html)
|
[WARN] : TiWebViewBinding: (KrollRuntimeThread) [3245,27900] Timeout waiting to evaluate JS
|
To reproduce:
var win = Ti.UI.createWindow({ |
backgroundColor:'white' |
});
|
|
var webView = Ti.UI.createWebView({ |
html:'<html><head></head><body><p><a href="Yoyo">Hello</a></p></body></html>' |
});
|
|
webView.addEventListener('load', function( e ) { |
// replace all a-href with javascript links to capture in Titanium |
webView.evalJS('(function(){var h,a=document.getElementsByTagName("a");for(var i=0,l=a.length;i<l;i++){h=a[i].attributes["href"];if(h && h.value && !String(h.value).match(/^#/) && String(h.value).indexOf("javascript:") === -1){h.value="javascript:Ti.App.fireEvent(\'linkClicked\',{href:\'"+h.value+"\'})"}}})();'); |
});
|
|
Ti.App.addEventListener('linkClicked', function( e ) { |
alert(e.href);
|
});
|
|
win.add(webView);
|
win.open();
|
The code works fine on iOS. The issue might be the same as TIMOB-15896.
Attachments
Issue Links
- relates to
-
TIMOB-17613 Unable to execute javascript code using evalJS on Android with SDK 3.3.0.GA
-
- Closed
-
-
TIMOB-15896 WebView's evalJS method times out on Android API >= 17
-
- Closed
-