AntViewDocument
The document interface is an additional interface to help you to communicate with the document presented in the WebView2 control. Almost all of the functionality is implemented with javascript.
The functions presented below are available as additional helper functions.
Note that by design, communication in javascript with the WebView2 component is all done in an asynchronous way.
This means that when you want data in return from the control, you first have to request in method a) for the data and then wait for event b) to be raised to retrieve the data you asked for.
This can make using this functionality in legacy development environments a bit challenging.
In order to help with that, most methods listed below also have a synchronous alternative.
It is important to know that you cannot use the synchronous methods directly from any of the events in the AntView control.
While the synchronous variants tend to be easier to use, we still recommend the asynchronous interface as that's "how the web works" and gives you most freedom, because it does not lock up the user interface while waiting for a task to complete.
Plus you can use the asynchronous methods from any of the AntView events.
The document interface can help by processing common tasks such as processing data in forms.
Some examples are:
- get/set data from input controls on html forms
- tick a checkbox
- press the submit button
- get/set content of html elements by Id or Name
- get/set the innerHtml of html elements by Id or Name
- send click to a html element
- test if a html element exists
- run javascript functions
One part that is in common with all the methods below is that you have to connect the document interface with the WebView2 control before you can use it.
You do this with either the CurrentBrowser property or with the BrowserDispatch method when you want to connect it to the Browser, or the FrameDispatch method if you want to connect it to an iframe object.
Properties
Methods
ElementClickByQuerySelectorSync
ElementRemoveAttributeByIdSync
ElementRemoveAttributeByNameSync
ElementToggleAttributeByIdSync
ElementToggleAttributeByNameSync
RequestElementAttributeByIdSync
RequestElementAttributeByNameSync
RequestElementExistsByNameSync
RequestElementInnerHTMLByIdSync
RequestElementInnerHTMLByNameSync
RequestElementInnerTextByIdSync
RequestElementInnerTextByNameSync
RequestInputCheckboxByNameSync
Events
OnElementRemoveAttributeByName
OnElementToggleAttributeByName
OnRequestElementAttributeByName
OnRequestElementInnerHTMLByName
OnRequestElementInnerTextByName
AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/25/2024