Android Question Run a Javascript embedded within an HTML document from B4a

Rusty

Well-Known Member
Licensed User
Longtime User
I have an HTML document that contains this java script:
B4X:
<script>
function myFunction() {
  var elmnt = document.getElementById("Q1");
  elmnt.scrollIntoView();
}
</script>
If I put an input of type button within the HTML, and click it, it works fine and scrolls to the item with ID="Q1" :)
I would like to be able to, from within my B4a code execute the myFunction while I:
  1. pass a parameter into the myFunction like myFunction("Q1")
  2. and programmatically "click" or execute the java script function from B4a code
Is this possible? If so, how might I go about this?

If this is not possible, is there a way from within B4a code to scroll to an ID within the Webview HTML?
Thanks
Rusty
 

JohnC

Expert
Licensed User
Longtime User
Use WebViewExtras:

B4X:
wve.executeJavascript(wv, "myFunction('Q1')")
 
Upvote 0
Top