| Parameter | Description |
|---|---|
| sScript | Script to execute |
Procedure ExecuteScript String sScript
| Call: | Send ExecuteScript sScript |
Executes a script within the current top-level document of the WebView2 control.
This method works asynchronously and will return immediately.
This method works exactly like the ExecuteScript function, except that the unique script identifier is not returned.
The example below shows how to execute a script within a page:
Object oWebView2Browser is a cWebView2Browser
Set Size to 87 250
Set Location to 0 0
Set psLocationURL to "https://support.dataaccess.com"
Set peAnchors to anAll
Procedure OnNavigationCompleted UBigInt iNavigationId String sUrl Boolean bIsSuccess OLECOREWEBVIEW2_WEB_ERROR_STATUS eWebErrorStatus
If (Lowercase(sUrl) contains "https://support.dataaccess.com") ;
Send ExecuteScript @'
function sayHello(){
const eWelcome = document.querySelector("ul.isuser li.welcomelink a");
if(eWelcome){
alert("Hello " + eWelcome.text + "!");
}else{
alert("Hello unknown user!");
}
}
sayHello();
'
End_Procedure
End_Object