- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi, I builded a simple test app for Android with XDK and it works perfectly in the emulator in Android 4.0, 4.2, 4.3, but the JavaScript code does not work neither in Android 4.4, nor 5.0, 5.1, 6.0, 7.0. Could someone help me to understand what is wrong ? Thanks. Here is the code:
<body>
<script>
function getText() {
document.getElementById('replace_text').innerHTML = 'A simple line';
}
</script>
<a href="#" onclick="getText()">Click here to replace text.</a>
<br />
<div id="replace_text">Here is the text to replace.</div>
</body>
- Etiquetas:
- HTML5
- Intel® XDK
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Android 4.4 is the first version where the HTML5 runtime engine is based on Chrome, so that represents a big change in the interpreter. My suspicion is you are running into some problem with CSP rules or similar, such as running JavaScript in an html file has been disabled, or something similar.
Try putting your JS in a js file and don't use "onclick" directly in the html. See the "blank cordova starter app" for an example of how to separate your html from you js. Specifically, see these lines > https://github.com/gomobile/sample-cordova-starter-app/blob/master/www/js/init-app.js#L70 <
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Android 4.4 is the first version where the HTML5 runtime engine is based on Chrome, so that represents a big change in the interpreter. My suspicion is you are running into some problem with CSP rules or similar, such as running JavaScript in an html file has been disabled, or something similar.
Try putting your JS in a js file and don't use "onclick" directly in the html. See the "blank cordova starter app" for an example of how to separate your html from you js. Specifically, see these lines > https://github.com/gomobile/sample-cordova-starter-app/blob/master/www/js/init-app.js#L70 <
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
It worked, thanks a lot. I just put my click event in "init-app.js", inside of the function "app.initEvents". Thus, I think it was not a problem with CSP rules. My JS code had just to be loaded when the app initalizes. It worked in the emulator from Android 4.0 to 7.0. Thanks.
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla