App inventor 2 en español
Cómo programar los teléfonos móviles con Android.
Curso de App inventor 2 en español - Juan Antonio Villalpando
-- Tutorial de iniciación de App Inventor 2 en español --
Volver al índice del tutorial
___________________________
169T.- JavaScript inyección de código.
p169T_inyeccion.aia
- Tenemos un código JavaScript, ese código lo vamos a insertar en una página web para modificar esa página cuando la vean los usuarios.
inject.js |
var logo = document.getElementById('hplogo');
logo.src = "https://pbs.twimg.com/profile_images/529214699041067008/fqPBAr5s_bigger.jpeg"; |
- Este ejemplo cambia el logo de Google por una foto del Dalai Lama.
_________________
- Diseño.
- Subi
_________________
- Bloques.
______________________________________________________________________
- Otro código.
inject.js |
/*
TEXT FILE: jsInject.js
Contains custom Javascript to be added to your target web page
You can do anything with the DOM from here, and none of this example code is essential, you can delete it ALL and replace it with your own.
*/
//Example function that just reads the variables from the URL's query string
var getUrlVars = function (name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
var msg = getURLVars('aVariableOnYourQueryString');
//pass text information back to your app through webViewString
window.AppInventor.setWebViewString(msg); |
__________________________________
|