CoreWebView2 Class
Definition
WebView2 enables you to host web content using the latest Microsoft Edge browser and web technology.
public class CoreWebView2
type CoreWebView2 = class
Public Class CoreWebView2
- Inheritance
-
CoreWebView2
Properties
BrowserProcessId |
Gets the process ID of the browser process that hosts the WebView. |
CanGoBack |
|
CanGoForward |
|
ContainsFullScreenElement |
Indicates if the WebView contains a fullscreen HTML element. |
CookieManager |
Gets the CoreWebView2CookieManager object associated with this CoreWebView2. |
DocumentTitle |
Gets the title for the current top-level document. |
Environment |
Exposes the CoreWebView2Environment used to create this CoreWebView2. |
IsSuspended |
Whether WebView is suspended. |
Settings |
Gets the CoreWebView2Settings object contains various modifiable settings for the running WebView. |
Source |
Gets the URI of the current top level document. |
Methods
AddHostObjectToScript(String, Object) |
Adds the provided host object to script running in the WebView with the specified name. |
AddScriptToExecuteOnDocumentCreatedAsync(String) |
Adds the provided JavaScript to a list of scripts that should be run after the global object has been created, but before the HTML document has been parsed and before any other script included by the HTML document is run. |
AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext) |
Adds a URI and resource context filter to the WebResourceRequested event. |
CallDevToolsProtocolMethodAsync(String, String) |
Runs an asynchronous DevToolsProtocol method. |
CapturePreviewAsync(CoreWebView2CapturePreviewImageFormat, Stream) |
Captures an image of what WebView is displaying. |
ClearVirtualHostNameToFolderMapping(String) |
Clears a host name mapping for local folder that was added by SetVirtualHostNameToFolderMapping(String, String, CoreWebView2HostResourceAccessKind). |
ExecuteScriptAsync(String) |
Runs JavaScript code from the |
GetDevToolsProtocolEventReceiver(String) |
Gets a DevTools Protocol event receiver that allows you to subscribe to a DevToolsProtocol event. |
GoBack() |
Navigates the WebView to the previous page in the navigation history. |
GoForward() |
Navigates the WebView to the next page in the navigation history. |
Navigate(String) |
Causes a navigation of the top level document to the specified URI. |
NavigateToString(String) |
Initiates a navigation to |
NavigateWithWebResourceRequest(CoreWebView2WebResourceRequest) |
Navigates using a constructed CoreWebView2WebResourceRequest object. |
OpenDevToolsWindow() |
Opens the DevTools window for the current document in the WebView. |
PostWebMessageAsJson(String) |
Posts the specified |
PostWebMessageAsString(String) |
Posts a message that is a simple String rather than a JSON string representation of a JavaScript object. |
Reload() |
Reloads the current page. |
RemoveHostObjectFromScript(String) |
Removes the host object specified by the name so that it is no longer accessible from JavaScript code in the WebView. |
RemoveScriptToExecuteOnDocumentCreated(String) |
Removes the corresponding JavaScript added via AddScriptToExecuteOnDocumentCreatedAsync(String) with the specified script ID. |
RemoveWebResourceRequestedFilter(String, CoreWebView2WebResourceContext) |
Removes a matching WebResource filter that was previously added for the WebResourceRequested event. |
Resume() |
Resumes the WebView so that it resumes activities on the web page. |
SetVirtualHostNameToFolderMapping(String, String, CoreWebView2HostResourceAccessKind) |
Sets a mapping between a virtual host name and a folder path to make available to web sites via that host name. |
Stop() |
Stops all navigations and pending resource fetches. |
TrySuspendAsync() |
An app may call this API to have the WebView2 consume less memory. |
Events
ContainsFullScreenElementChanged |
ContainsFullScreenElementChanged is raised when the ContainsFullScreenElement property changes. |
ContentLoading |
ContentLoading is raised before any content is loaded, including scripts added with AddScriptToExecuteOnDocumentCreatedAsync(String). ContentLoading is not raised if a same page navigation occurs (such as through fragment navigations or |
DocumentTitleChanged |
DocumentTitleChanged is raised when the DocumentTitle property changes and may be raised before or after the NavigationCompleted event. |
DOMContentLoaded |
DOMContentLoaded is raised when the initial HTML document has been parsed. |
FrameNavigationCompleted |
FrameNavigationCompleted is raised when a child frame has completely loaded ( |
FrameNavigationStarting |
FrameNavigationStarting is raised when a child frame in the WebView requests permission to navigate to a different URI. |
HistoryChanged |
HistoryChanged is raised when there is change of navigation history for the top level document. |
NavigationCompleted |
NavigationCompleted is raised when the WebView has completely loaded ( |
NavigationStarting |
NavigationStarting is raised when the WebView main frame is requesting permission to navigate to a different URI. |
NewWindowRequested |
NewWindowRequested is raised when content inside the WebView requests to open a new window, such as through |
PermissionRequested |
PermissionRequested is raised when content in a WebView requests permission to access some privileged resources. |
ProcessFailed |
ProcessFailed is raised when a WebView process ends unexpectedly or becomes unresponsive. |
ScriptDialogOpening |
ScriptDialogOpening is raised when a JavaScript dialog ( |
SourceChanged |
SourceChanged is raised when the Source property changes. |
WebMessageReceived |
WebMessageReceived is raised when the IsWebMessageEnabled setting is set and the top-level document of the WebView runs |
WebResourceRequested |
WebResourceRequested is raised when the WebView is performing a URL request to a matching URL and resource context filter that was added with AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext). |
WebResourceResponseReceived |
WebResourceResponseReceived is raised when the WebView receives the response for a request for a web resource (any URI resolution performed by the WebView; such as HTTP/HTTPS, file and data requests from redirects, navigations, declarations in HTML, implicit favicon lookups, and fetch API usage in the document). The host app can use this event to view the actual request and response for a web resource. There is no guarantee about the order in which the WebView processes the response and the host app's handler runs. The app's handler will not block the WebView from processing the response. |
WindowCloseRequested |
WindowCloseRequested is raised when content inside the WebView requested to close the window, such as after |