Variable with javascript

Hi Is possible to get a variable of a webpage?? the html is online and not in my assets app

I already can run a function but I need to know the value of a variable, how can I do that?

I am trying with document.getElementById('captcha').value

but it says cannot read property value of null

the var is a boolean

what can I do?

pitagoras5

p166_javascript_pitagoras_web.aia (2.8 KB)

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head><body>
<script>

    datos =  window.AppInventor.getWebViewString(); // Entrada de datos.
    datos = datos + ":";  
  
    catetos = datos.split(":"); 
    cateto1 = catetos[0];
    cateto2 = catetos[1];
    
    hipotenusa = Math.sqrt(Math.pow(cateto1, 2) + Math.pow(cateto2, 2)) ;
   
   window.AppInventor.setWebViewString("" + hipotenusa);  // Respuesta a CadenaDeWebView
   
</script>
</body></html>

Like this example?

<!DOCTYPE html>
<html>
<meta name=“viewport” content=“width=device-width, initial-scale=1.0”>

<head>
	<title>TestJS</title>
	
</head>

<body>
	<p id = "test">Hello World</p>
</body>

</html>

image

I have the same error, cannot read property "innerHTML" of null
<
script type="text/javascript">
var captcha = false;
function datacallback() {
captcha = true;
};
var t = "";

that's the script on the html file, So i want to know the value of var catcha .

<head><meta charset="utf-8"></head><body>
<script>

var captcha = false;

function datacallback() {
captcha = true;
window.AppInventor.setWebViewString(captcha);  
};
datacallback();

</script>
</body></html>
1 Like

this works if I modified the html adding "window.AppInventor.setWebViewString(captcha)" , but is not other way?

without modify the html