Android WebView crashes on AddEventListener
Adding the following to the Webview seems to crash it on Android. Anyone had any success with it? or is it a known bug?
This means I will have to recreate my HTML over an over again to update it?
Ti SDK: 1.8.1
Platform: Android
Version: 2.3.3
Device/Emulator: emulator
Developing on: OSX
var html = '<html>' +
'<head><meta name="viewport" content="width=device-width; initial-scale=1.0; user-scalable=no;" />' +
'<style>' +
' body {font-family:Arial Rounded MT Bold, Arial; font-size:14px;}' +
' p {font-family:Arial Rounded MT Bold, Arial; font-size:14px;}' +
'</style></head>' +
'<body>' +
'<div id="test">No Event</div>' +
'<script type="text/javascript">' +
'Ti.App.addEventListener(\'SomethingStrange\', function(e) { ' +
' document.getElementById( \'test\' ).innerHTML = \'Got the event\';' +
'});' +
'</script>' +
'</body>' +
'</html>';
var webview = Ti.UI.createWebView({
top: 0,
left: 0,
backgroundColor: '#ffffff',
scalesPageToFit: true,
html: html
});
2 Answers
-
Hi have you tried saving the html code in inside the HTML page and then loading it in the web-view? Give that a try might it solve the problem.
Regards
Nikunj
-
there is a bug with android 2.3.3 with webview event within simulator, but it's fine when you publish in really device (android 2.3.3), so you can use android 4.0 for testing with the simulator