WebControlWrapper can't get correct value of 'document.getElementById("div-name").innerHTML'

Hello.

I’m fiddling with a WebControlWrapper built so I can retrieve the content of php script from an external site. The resulting text of such script is something like:

It is a fingerprint template, to be processed in a time and attendance web app.

I would prefer getting the result of the script (which activates a fingerprint reader on the user machine), simulated here, with a simpler HTTPSocket. Unfortunately it does not work with the fingerprint reading php script, although it does work wth the simulation above.

I also tried with WebHTMLViewer and could get it to work, setting its URL property as the php (or the simulation) address. I couldn’t find a way to get the system to “read” the contents of the WebHTMLViewer and out it into a string variable.

Following old discussions on the forum around the subject, like this one, I found some techniques using WebControlWrapper.

I can make the WebControlWrapper read the information needed but it fails to access the DOM thorugh Javascript and fetch data. I know for sure the data is there. It shows on the ‘Developer Tools’ on Chrome…

Sample project is here.

This is what I have on a button to start fetching data after the WebControlWrapper has finished receiving data:

If ControlAvailableInBrowser() Then
      ExecuteJavaScript(ReplaceAll(TakeFIR, "<<ControlID>>", Self.ControlID))
End If

This is the constant ‘TakeFIR’:

Xojo.triggerServerEvent('<<ControlID>>','HASFIR',document.getElementById("<<ControlID>>").document.innerHTML);

And this is the ExecuteEvent event:

		If Parameters.Ubound = -1 Then
				MsgBox("empty string")
				
		Else
				
				Select Case Name
				Case "HASFIR"
						Dim s As String = NthField(Parameters(0), ",", 2)
						RaiseEvent HASFIR(s)
				End Select
				
		End If

Any ideas on why it does not work? Any way to make it work?

Xojo.triggerServerEvent takes an array as third argument. You are handing over a value. Wrap it in [].

Aha!

It works!

Thanks a lot, Eli Ott!

One more step to go, though…

Xojo.triggerServerEvent('<<ControlID>>','HASFIR',[document.getElementById("<<ControlID>>").document.innerHTML)]);

Returns:

<object type="text/html" data="http://lbworks.com.br/biometrics/myFIR.txt&#10;" width="320px" height="240px" style="overflow:auto;border:1px ridge black">
	<object type="text/html" data="http://lbworks.com.br/biometrics/myFIR.txt&#10;" width="320px" height="240px" style="overflow:auto;border:1px ridge black">
</object>

The full content of the node is:

<object type="text/html" data="http://lbworks.com.br/biometrics/myFIR.txt&#10;" width="320px" height="240px" style="overflow:auto;border:1px ridge black">
	<object type="text/html" data="http://lbworks.com.br/biometrics/myFIR.txt&#10;" width="320px" height="240px" style="overflow:auto;border:1px ridge black">
	#document
	<html>
		<head>
		</head>
		<body>
AQAAABQAAAD0AAAAAQASAAEAZAAAAAAA7AAAADcTLHBkfr2SLdzhGN6LoMElI4XnTp*xnYgQB*FP4OZeVcx5mRaQT3viUaMh4w3uBPYgTKLTS5uct31RCIZpEdlrbMumfhFmEY*tDxWx7Ng
		</body>
	</html>
</object>

How to get access to the tag inside the element, where the “AQAAABQAAAD0AAAAAQASAAEAZAA…” string is?

Look at the property contentDocument. Don’t know if this works though. And you might not be able to do that due to cross-site scripting restrictions. Also note that you try to get this info after the page and the “inner” page are fully loaded, or you’ll get ‘undefined’.