Accessing html elements in web viewer

We wrote DOM classes previously for MacOS HTMLViewer, but as you now have 5 engines, we prefer to use JavaScript.

You are welcome to download MBS Plugins and try all the methods above.

[quote=470412:@Guenter Kraemer]So that wont help me at all.

I have a Win Desktop app, with a htmlviewer, and just want to fill the formfields and submit the form.
In Delphi, I use the document interface, exposed by the browser control, but I cant find something similar in the htmlviewer control.[/quote]

Christian is in error. ExecuteJavaScript is one of the methods of HTMLViewer DESKTOP.

I don’t suspect him of simply trying to sell his stuff. He probably forgot :wink:

+1

+1

This one works

js = "document.forms[0].elements['your-name'].value=""test only"";"
HTMLViewer1.executejavascript(js)

but not the other

js = "document.getElementByName('your-name').value='test only';"
HTMLViewer1.executejavascript(js)

that give me an OELException

If you [quote=470458:@Michel Bujardet]Christian is in error. ExecuteJavaScript is one of the methods of HTMLViewer DESKTOP.

I don’t suspect him of simply trying to sell his stuff. He probably forgot ;)[/quote]

Sorry. When you search on the documentation page for ExecuteJavaScript, you end up only with the web entry: ExecuteJavaScript
But now I found it: HTMLViewer.ExecuteJavaScript

Still if you need a result, you better try our plugin.

I think that must be document.getElementsByName and returns an array, so you need the [0] there.
(in hope that IE supports it)

[quote=470412:@Guenter Kraemer]So that wont help me at all.

I have a Win Desktop app, with a htmlviewer, and just want to fill the formfields and submit the form.
In Delphi, I use the document interface, exposed by the browser control, but I cant find something similar in the htmlviewer control.[/quote]
Do you control the content of the HTMLViewer? By this I mean, did you write the HTML and javascript in the HTMLViewer, or did some unknown person write it?

[quote=470469:@Guenter Kraemer]js = “document.getElementByName(‘your-name’).value=‘test only’;”
HTMLViewer1.executejavascript(js)
that give me an OELException[/quote]

All depends on the structure of the DOM. I had assumed a simple input tag.At any rate, I am glad you found a way by yourself.