interface ICoreWebView2ScriptDialogOpeningEventArgs
interface ICoreWebView2ScriptDialogOpeningEventArgs
: public IUnknown
Event args for the ScriptDialogOpening
event.
Members | Descriptions |
---|---|
Accept | The host may run this to respond with OK to confirm , prompt , and beforeunload dialogs. |
get_DefaultText | The second parameter passed to the JavaScript prompt dialog. |
get_Kind | The kind of JavaScript dialog box. |
get_Message | The message of the dialog box. |
get_ResultText | The return value from the JavaScript prompt function if Accept is run. |
get_Uri | The URI of the page that requested the dialog box. |
GetDeferral | Returns an ICoreWebView2Deferral object. |
put_ResultText | Sets the ResultText property. |
Product | Introduced |
---|---|
WebView2 Win32 | 0.9.430 |
WebView2 Win32 Prerelease | 0.9.488 |
The host may run this to respond with OK to confirm
, prompt
, and beforeunload
dialogs.
public HRESULT Accept()
Do not run this method to indicate cancel. From JavaScript, this means that the confirm
and beforeunload
function returns TRUE
if Accept
is run. And for the prompt function it returns the value of ResultText
if Accept
is run and otherwise returns FALSE
.
The second parameter passed to the JavaScript prompt dialog.
public HRESULT get_DefaultText(LPWSTR * defaultText)
The result of the prompt JavaScript function uses this value as the default value.
The caller must free the returned string with CoTaskMemFree
. See API Conventions.
The kind of JavaScript dialog box.
public HRESULT get_Kind(COREWEBVIEW2_SCRIPT_DIALOG_KIND * kind)
alert
, confirm
, prompt
, or beforeunload
.
The message of the dialog box.
public HRESULT get_Message(LPWSTR * message)
From JavaScript this is the first parameter passed to alert
, confirm
, and prompt
and is empty for beforeunload
.
The caller must free the returned string with CoTaskMemFree
. See API Conventions.
The return value from the JavaScript prompt function if Accept
is run.
public HRESULT get_ResultText(LPWSTR * resultText)
This value is ignored for dialog kinds other than prompt. If Accept
is not run, this value is ignored and FALSE
is returned from prompt.
The caller must free the returned string with CoTaskMemFree
. See API Conventions.
The URI of the page that requested the dialog box.
public HRESULT get_Uri(LPWSTR * uri)
The caller must free the returned string with CoTaskMemFree
. See API Conventions.
Returns an ICoreWebView2Deferral object.
public HRESULT GetDeferral(ICoreWebView2Deferral ** deferral)
Use this operation to complete the event at a later time.
Sets the ResultText
property.
public HRESULT put_ResultText(LPCWSTR resultText)