problem with WebBrowser

Byak@

Active Member
Licensed User
in my app i want use webbrowser as Option's dialog.i think it is very сomfortably.
i'm create a html document with textbox and checkbox.and i want get documenttext (when i fill textbox and check checbox) and then parse it.
but DocumentText in WebBrowserEx return to me old documenttext that I create at the beginning! (without changes)

i'm found in msdn new(for me) parametr and sample but i don't understand how use it in basic WebBrowser.Document - ???????? (System.Windows.Forms)

example
 

Attachments

  • ex.zip
    11.8 KB · Views: 190

ExcludeReality

Active Member
Licensed User
It seems DocumentText returns the source code of the page.
You should use JavaScript to get properties and values of the HTML forms.

Example:
B4X:
<html>
<head>
<script type="text/javascript">
function getValue()
{
alert(document.getElementById("text1").value);
alert(document.getElementById("check1").checked);
}
</script>
</head>
<body>

<form>
<input type="text" id="text1" value="Type me" />
<input type="checkbox" id="check1" value="Check me" checked/>
<input type="button" id="button1" onclick="getValue()" value="Show value" />
</form>

</body>
</html>

"Document.getElementById("text1").value" gets the current value of the text box.
"Document.getElementById("check1").checked" gets the current state of the checkbox
Try to do some additional research
 
Last edited:

Byak@

Active Member
Licensed User
ooo,big thanks!but how can i get this values to my program?and i not want msgboxes...help please
 

ExcludeReality

Active Member
Licensed User
I think the only way to do this is to write the values to a file, and then read the file from your application.

For example:
B4X:
<html>
<head>
<script type="text/javascript">
function getValue()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var FileObject = fso.OpenTextFile("Test.txt", 8, true,0);
FileObject.write(document.getElementById("text1").value)
FileObject.close()
}
</script>
</head>
<body>

<form>
<input type="text" id="text1" value="Type me" />
<input type="checkbox" id="check1" value="Check me" checked/>
<input type="button" id="button1" onclick="getValue()" value="Show value" />
</form>

</body>
</html>

This will write the text in the textbox to the file Test.txt.
Read the file with your application to get the values.

NOTE: This example will only work with Internet Explorer, Since it uses an ActiveX object.
I'm not sure if Agrahams WebBrowser control allows ActiveX, but you should give it a shot
 

Cableguy

Expert
Licensed User
Longtime User
It seems DocumentText returns the source code of the page.
That is a correct assumption.

"Document.getElementById("text1").value" gets the current value of the text box.
This is already implemented in the WebBrowserEX Dll, in wich it is possible to eithet get/set the value of a give control, either by name or by ID...
"Document.getElementById("check1").checked" gets the current state of the checkbox
Try to do some additional research
This is Not implemented im my WebBrowserEX, as I only added the "I need this" features in it, and no user ever asked for it...
Still it would be far more easy to simply scout the documenttext, for the given control changes, than to include a get method for every control type.
 

ExcludeReality

Active Member
Licensed User
Sorry Cableguy, I thaught Agraham made get WebBrowser library.
I must have confused it with the htmlPanel.

Still it would be far more easy to simply scout the documenttext, for the given control changes

I'm not sure I follow. The way I see it Javascript is the only way to get properties
 

agraham

Expert
Licensed User
Longtime User
I thaught Agraham made get WebBrowser library.
I did! WebBrowser runs on both device and desktop and as such offers strictly only the capabilities supported on the device.

Cableguy took the WebBrowser source code and added some desktop only capabilities to produce WebBrowserEx that will only run on the desktop.
 

Byak@

Active Member
Licensed User
This is already implemented in the WebBrowserEX Dll, in wich it is possible to eithet get/set the value of a give control, either by name or by ID...
i'm try but not happend...
This is Not implemented im my WebBrowserEX, as I only added the "I need this" features in it, and no user ever asked for it...
Still it would be far more easy to simply scout the documenttext, for the given control changes, than to include a get method for every control type.
Please make though something with it
webbrowser very convenient control and to use it as the interface of the program it would be healthy!
 
Last edited:

ExcludeReality

Active Member
Licensed User
I did! WebBrowser runs on both device and desktop and as such offers strictly only the capabilities supported on the device.

Cableguy took the WebBrowser source code and added some desktop only capabilities to produce WebBrowserEx that will only run on the desktop.

:confused: This is so confusing. Why don't you just combine all the WebBrowsers into one super-browser library?
I'm waiting for it :)
 

agraham

Expert
Licensed User
Longtime User
Why don't you just combine all the WebBrowsers into one super-browser library?
Because it is just not possible! If you want a WebBrowser to run on the device then the WebBrowser library does all that a device supports and will run on the desktop as a bonus.

If you want the extra capabilities that a desktop can offer then WebBrowserEx offers some of them but because those capabilitie are not present on the device WebBrowserEx will not run on the device. Period!
 
Top