B4J Question access to array variables by webview

bogdanc

Active Member
Licensed User
Longtime User
Hi All!

I used a webview to open my external web.
that web has continuously updating (Ajax / js ) some variables.
These variables are kept in the array.

How to get access to them?

Is there any simplest way instead of use a webview.

Thanks for any ideas.
 

eurojam

Well-Known Member
Licensed User
Longtime User
you asked a similar question already in b4j forum. I suppose the answer will be the same like Erel gave you some days before...;)
 
Upvote 0

bogdanc

Active Member
Licensed User
Longtime User
you asked a similar question already in b4j forum. I suppose the answer will be the same like Erel gave you some days before...;)

Yes was similar but This time is about variable value kept in the array.
How to get access to it?
 
Upvote 0

bogdanc

Active Member
Licensed User
Longtime User
You will need to inject JavaScript that reads the array. A better solution will be to remove WebView and use HttpUtils2 to make the requests.


Hi Erel!

I did some simple example:
HTML:
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script>
    var test = ["element1", "element2", "element3"];
    </script>
    <body>  
    </body>
</html>


Then I used a tutorial of: HttpUtils2

But id downloading is as plain text.

So how in this method request access to array?
 
Upvote 0

bogdanc

Active Member
Licensed User
Longtime User
You will need to parse it the html.
This regex pattern will return the text inside the square brackets:
\[([^]]+)\]

You can then split it and remove spaces and quotes to get the elements.

I understand but an array its dymamicly updated. So I will need to gor example:
Array: test[0] to get this element
 
Upvote 0
Top