| title | Overview of WebView2 features and APIs |
|---|---|
| description | Overview of WebView2 features and APIs. |
| author | MSEdgeTeam |
| ms.author | msedgedevrel |
| ms.topic | conceptual |
| ms.prod | microsoft-edge |
| ms.technology | webview |
| ms.date | 04/14/2023 |
Embedding the WebView2 control in your app gives your app access to various methods and properties that are provided through the WebView2 classes or interfaces. WebView2 has hundreds of APIs that provide a vast set of capabilities, ranging from enhancing your app's native-platform capabilities, to enabling your app to modify browser experiences. This article provides a high-level grouping of the WebView2 APIs to help you understand the different things you can do using WebView2.
When hosting the WebView2 control, your app has access to the following features and APIs:
| Feature area | Purpose |
|---|---|
| Main classes: Environment, Controller, and Core | The CoreWebView2Environment, CoreWebView2Controller, and CoreWebView2 classes (or equivalent interfaces) work together so your app can host a WebView2 browser control and access its browser features. These large classes expose a wide range of APIs that your host app can access to provide the below categories of browser-related features for your users. |
| Web/native interop | Embed web content into native applications. Communicate between native code and web code using simple messages, JavaScript code, and native objects. |
| Browser features | The WebView2 control gives your app access to many browser features. You can modify these browser features and turn them on or off. |
| Process management | Get information about running WebView2 processes, exiting processes, and failed processes, so your app can take action accordingly. |
| Navigate to pages and manage loaded content | Manage navigation to webpages and manage content that's loaded in the webpages. |
| iframes | Embed other webpages into your own webpage. Detect when embedded webpages are created, detect when embedded webpages are navigating, and optionally bypass x-frame options. |
| Authentication | Your app can handle basic authentication using the WebView2 control. Basic authentication is a specific authentication approach that's part of the HTTP protocol. |
| Rendering WebView2 in non-framework apps | Use these APIs to set up the WebView2 rendering system if your host app doesn't use a UI framework. This rendering setup controls how WebView2 renders output into your host app, and how WebView2 handles input, focus, and accessibility. |
| Rendering WebView2 using Composition | For composition-based WebView2 rendering, use CoreWebView2Environment to create a CoreWebView2CompositionController. CoreWebView2CompositionController provides the same APIs as CoreWebView2Controller, but also includes APIs for composition-based rendering. |
| User data | Manage the user data folder (UDF), which is a folder on the user's machine. The UDF contains data related to the host app and WebView2. WebView2 apps use user data folders to store browser data, such as cookies, permissions, and cached resources. Manage multiple profiles under a single UDF. |
| Performance and debugging | Analyze and debug performance, handle performance-related events, and manage memory usage to increase the responsiveness of your app. |
| Chrome Developer Protocol (CDP) | Instrument, inspect, debug, and profile Chromium-based browsers. The Chrome DevTools Protocol is the foundation for the Microsoft Edge DevTools. Use the Chrome DevTools Protocol for features that aren't implemented in the WebView2 platform. |
The CoreWebView2Environment, CoreWebView2Controller, and CoreWebView2 classes (or equivalent interfaces) work together so your app can host a WebView2 browser control and access its browser features. These three large classes expose a wide range of APIs that your host app can access to provide many categories of browser-related features for your users.
- The
CoreWebView2Environmentclass represents a group of WebView2 controls that share the same WebView2 browser process, user data folder, and renderer processes. From thisCoreWebView2Environmentclass, you create pairs ofCoreWebView2ControllerandCoreWebView2instances. - The
CoreWebView2Controllerclass is responsible for hosting-related functionality such as window focus, visibility, size, and input, where your app hosts the WebView2 control. - The
CoreWebView2class is for the web-specific parts of the WebView2 control, including networking, navigation, script, and parsing and rendering HTML.
See also:
The Microsoft Edge WebView2 control lets you embed web content into native applications. You can communicate between native code and web code using simple messages, JavaScript code, and native objects.
Some common use cases include:
- Update the native host window title after navigating to a different website.
- Send a native camera object and use its methods from a web app.
- Run a dedicated JavaScript file on the web side of an application.
See also:
- Interop of native-side and web-side code
- Call web-side code from native-side code
- Call native-side code from web-side code
- Call native-side WinRT code from web-side code
- JavaScript APIs in WebView2 for
window.chrome.webviewJavaScript APIs
The following are the main APIs for communicating between web and native code.
WebView2 enables objects that are defined in native code to be passed to your app's web-side code. Host objects are any objects that are defined in native code that you choose to pass to your app's web-side code.
Host objects can be projected into JavaScript, so that you can call native object methods (or other APIs) from your app's web-side code. For example, your app can call such APIs as a result of user interaction on the web side of your app. This way, you don't need to reimplement your native objects' APIs, such as methods or properties, in your web-side code.
Allows host app to add JavaScript in the web content within the WebView2 control.
Your app can send messages to the web content that's within the WebView2 control, and receive messages from that web content. Messages are sent as strings or JSON objects.
When hosting WebView2, your app can manage different JavaScript dialogs, to suppress them or to replace them with custom dialogs.
The SharedBuffer API supports sharing buffers between the WebView2 host app process and WebView2 renderer process, based on shared memory from the OS.
-
CoreWebView2Class -
CoreWebView2EnvironmentClass -
CoreWebView2FrameClass -
CoreWebView2SharedBufferAccess Enum
ReadOnlyReadWrite
-
CoreWebView2Class -
CoreWebView2EnvironmentClass -
CoreWebView2FrameClass -
CoreWebView2SharedBufferAccess Enum
ReadOnlyReadWrite
-
COREWEBVIEW2_SHARED_BUFFER_ACCESS
COREWEBVIEW2_SHARED_BUFFER_ACCESS_READ_ONLYCOREWEBVIEW2_SHARED_BUFFER_ACCESS_READ_WRITE
The WebView2 control gives your app access to many browser features. You can modify these browser features and turn them on or off.
You can print a webpage to a printer, PDF file, or PDF stream by configuring custom print settings.
See also:
-
ICoreWebView2_16 -
PrintSettings
You can use cookies in WebView2 to manage user sessions, store user personalization preferences, and track user behavior.
See also:
By hosting WebView2, your app can capture screenshots and indicate which format to use to save the image.
Your app can manage the download experience in WebView2. Your app can:
- Allow or block downloads based on different metadata.
- Change the download location.
- Configure a custom download UI.
- Customize the default UI.
General:
- CoreWebView2.IsDefaultDownloadDialogOpenChanged Event
- CoreWebView2.IsDefaultDownloadDialogOpen Property
- CoreWebView2.OpenDefaultDownloadDialog Method
- CoreWebView2.CloseDefaultDownloadDialog Method
Modify Default Experience:
- CoreWebView2.DefaultDownloadDialogCornerAlignment Property
- CoreWebView2.DefaultDownloadDialogMargin Property
- CoreWebView2Profile.DefaultDownloadFolderPath Property
Custom Download Experience:
General:
- CoreWebView2.IsDefaultDownloadDialogOpenChanged Event
- CoreWebView2.IsDefaultDownloadDialogOpen Property
- CoreWebView2.OpenDefaultDownloadDialog Method
- CoreWebView2.CloseDefaultDownloadDialog Method
Modify Default Experience:
- CoreWebView2.DefaultDownloadDialogCornerAlignment Property
- CoreWebView2.DefaultDownloadDialogMargin Property
- CoreWebView2Profile.DefaultDownloadFolderPath Property
Custom Download Experience:
General:
- ICoreWebView2_9::IsDefaultDownloadDialogOpen property (get)
- ICoreWebView2_9::OpenDefaultDownloadDialog method
- ICoreWebView2_9::IsDefaultDownloadDialogOpenChanged event (add, remove)
- ICoreWebView2_9::CloseDefaultDownloadDialog method
Modify Default Experience:
- ICoreWebView2_9::DefaultDownloadDialogCornerAlignment property (get, put)
- ICoreWebView2_9::DefaultDownloadDialogMargin property (get, put)
- ICoreWebView2Profile::DefaultDownloadFolderPath property (get, put)
Custom Download Experience:
Different webpages may ask you for permissions to access some privileged resources, such as geolocation sensor, camera, and microphone. Your host app can programmatically respond to permissions requests and can replace the default permissions UI with its own UI.
-
CoreWebView2PermissionRequestedEventArgsEvent -
CoreWebView2ProfileClass
-
CoreWebView2PermissionRequestedEventArgsEvent -
CoreWebView2ProfileClass
The WebView2 control provides a default context menu (right-click menu) which you can customize or disable, and you can also create your own context menu.
See also:
A status bar is located in the bottom left of the page and displays the state of the webpage being displayed. In WebView2 you can enable/disable the status bar, get the text in the status bar, and find out when the status bar text has changed.
-
CoreWebView2 -
CoreWebView2Settings
-
CoreWebView2 -
CoreWebView2Settings
-
ICoreWebView2_12 -
ICoreWebView2Settings
The user agent is a string that represents the identity of the program on behalf of the user, such as the browser name. In WebView2, you can set the user agent.
See also:
Your app can independently control whether the browser's autofill functionality is enabled for general information or for passwords.
CoreWebView2Settings
CoreWebView2Settings
ICoreWebView2Settings4
Your app can mute and unmute all audio, and find out when audio is playing.
CoreWebView2
CoreWebView2
- ICoreWebView2_8
- ICoreWebView2_8::add_IsDocumentPlayingAudioChanged method
- ICoreWebView2_8::add_IsMutedChanged method
- ICoreWebView2_8::get_IsDocumentPlayingAudio method
- ICoreWebView2_8::get_IsMuted method
- ICoreWebView2_8::put_IsMuted method
- ICoreWebView2_8::remove_IsDocumentPlayingAudioChanged method
- ICoreWebView2_8::remove_IsMutedChanged method
By hosting the WebView2 control, your app can enable or disable swiping gesture navigation on touch input-enabled devices. This gesture allows end users to:
- Swipe left/right (swipe horizontally) to navigate to the previous or next page in the navigation history.
- Pull to refresh (swipe vertically) the current page.
This feature is currently disabled by default in the browser. To enable this feature in WebView2, set the AdditionalBrowserArguments property, specifying the --pull-to-refresh switch.
-
ICoreWebView2Settings6::IsSwipeNavigationEnabled property (get, put)
-
ICoreWebView2EnvironmentOptions::AdditionalBrowserArguments property (get, put)
In WebView2, you can find out when an HTML element enters or leaves full-screen view.
- ICoreWebView2::ContainsFullScreenElement property (get)
- ICoreWebView2::ContainsFullScreenElementChanged event (add, remove)
In the browser PDF viewer, there's a PDF-specific toolbar along the top. In WebView2, you can hide some of the items in the PDF viewer toolbar.
In WebView2, you can customize the color theme as system, light, or dark.
The Language property sets the default display language for WebView2 that applies to the browser UI (such as context menus and dialogs), along with setting the accept-language HTTP header which WebView2 sends to websites.
The ScriptLocale property allows the host app to set the default locale for all Intl JavaScript APIs and other JavaScript APIs that depend on it, such as Intl.DateTimeFormat(), which affects string formatting in time/date formats.
-
CoreWebView2ControllerOptionsClass
-
CoreWebView2ControllerOptionsClass
-
ICoreWebView2EnvironmentOptionsinterface
WebView2 provides functionality to handle the JavaScript function window.open().
WebView2 provides functionality to handle the JavaScript function window.close().
Your app can detect when the title of the current top-level document has changed.
In WebView2 you can you can set a Favicon for a website or get notified when it changes.
Enables the host app to control the level of tracking prevention of the WebView2 control that's associated with the user profile.
-
CoreWebView2EnvironmentOptionsClass -
CoreWebView2ProfileClass -
CoreWebView2TrackingPreventionLevel Enum
NoneBasicBalancedStrict
-
CoreWebView2EnvironmentOptionsClass -
CoreWebView2ProfileClass -
CoreWebView2TrackingPreventionLevel Enum
NoneBasicBalancedStrict
-
COREWEBVIEW2_TRACKING_PREVENTION_LEVEL enum
COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_NONECOREWEBVIEW2_TRACKING_PREVENTION_LEVEL_BASICCOREWEBVIEW2_TRACKING_PREVENTION_LEVEL_BALANCEDCOREWEBVIEW2_TRACKING_PREVENTION_LEVEL_STRICT
Get information about running WebView2 processes, exiting processes, and failed processes, so that your app can take action accordingly.
Info:
- CoreWebView2.BrowserProcessId Property
- CoreWebView2Environment.GetProcessInfos Method
- CoreWebView2Environment.ProcessInfosChanged Event
- CoreWebView2ProcessInfo Class
Exited:
Failed:
Info:
- CoreWebView2.BrowserProcessId Property
- CoreWebView2Environment.GetProcessInfos Method
- CoreWebView2Environment.ProcessInfosChanged Event
- CoreWebView2ProcessInfo Class
Exited:
Failed:
Info:
- ICoreWebView2::BrowserProcessId property (get)
- ICoreWebView2Environment8::GetProcessInfos method
- ICoreWebView2Environment8::ProcessInfosChanged event (add, remove)
- ICoreWebView2ProcessInfo interface
- ICoreWebView2ProcessInfoCollection interface
Exited:
Failed:
Through the WebView2 control, your app can manage navigation to webpages and manage content that's loaded in the webpages.
These APIs load, stop loading, and reload content to WebView2. The content that's loaded can be:
- Content from a URL.
- A string of HTML.
- Local content via virtual host name to local folder mapping.
- Content from a constructed network request.
See also:
- CoreWebView2.Navigate Method
- CoreWebView2.NavigateToString Method
- CoreWebView2.NavigateWithWebResourceRequest Method
- CoreWebView2.Stop Method
- CoreWebView2.Reload Method
- CoreWebView2.SetVirtualHostNameToFolderMapping Method
- CoreWebView2.ClearVirtualHostNameToFolderMapping Method
- CoreWebView2.WebResourceRequested Event
- CoreWebView2Settings.IsBuiltInErrorPageEnabled Property
- CoreWebView2.Navigate Method
- CoreWebView2.NavigateToString Method
- CoreWebView2.NavigateWithWebResourceRequest Method
- CoreWebView2.Stop Method
- CoreWebView2.Reload Method
- CoreWebView2.SetVirtualHostNameToFolderMapping Method
- CoreWebView2.ClearVirtualHostNameToFolderMapping Method
- CoreWebView2.WebResourceRequested Event
- CoreWebView2Settings.IsBuiltInErrorPageEnabled Property
- ICoreWebView2::Navigate method
- ICoreWebView2::NavigateToString method
- ICoreWebView2_2::NavigateWithWebResourceRequest method
- ICoreWebView2::Stop method
- ICoreWebView2::Reload method
- ICoreWebView2_3::SetVirtualHostNameToFolderMapping method
- ICoreWebView2_3::ClearVirtualHostNameToFolderMapping method
- ICoreWebView2::WebResourceRequested event (add, remove)
- ICoreWebView2Settings::IsBuiltInErrorPageEnabled property (get, put)
The history methods allow back and forward navigation in WebView2, and the history events provide information about the changes in history and in WebView2's current source.
- CoreWebView2.Source Property
- CoreWebView2.SourceChanged Event
- CoreWebView2.HistoryChanged Event
- CoreWebView2.CanGoBack Property
- CoreWebView2.CanGoForward Property
- CoreWebView2.Source Property
- CoreWebView2.SourceChanged Event
- CoreWebView2.HistoryChanged Event
- CoreWebView2.CanGoBack Property
- CoreWebView2.CanGoForward Property
- ICoreWebView2::Source property (get)
- ICoreWebView2::SourceChanged event (add, remove)
- ICoreWebView2::HistoryChanged event (add, remove)
- ICoreWebView2::CanGoBack property (get)
- ICoreWebView2::CanGoForward property (get)
The NavigationStarting event allows the app to cancel navigating to specified URLs in WebView2, including for frames.
Superseded:
Superseded:
- ICoreWebView2::NavigationStarting event (add, remove)
- ICoreWebView2Frame2::NavigationStarting event (add, remove)
Superseded:
With NavigationStarting and the other navigation events, the app can be informed of the state of navigation in WebView2. A navigation is the process for loading a new URL.
See also:
- CoreWebView2.ContentLoading Event
- CoreWebView2.DOMContentLoaded Event
- CoreWebView2.NavigationCompleted Event
- CoreWebView2.FrameNavigationCompleted Event
- CoreWebView2Frame.ContentLoading Event
- CoreWebView2Frame.DOMContentLoaded Event
- CoreWebView2Frame.NavigationCompleted Event
- CoreWebView2.ContentLoading Event
- CoreWebView2.DOMContentLoaded Event
- CoreWebView2.NavigationCompleted Event
- CoreWebView2.FrameNavigationCompleted Event
- CoreWebView2Frame.ContentLoading Event
- CoreWebView2Frame.DOMContentLoaded Event
- CoreWebView2Frame.NavigationCompleted Event
- ICoreWebView2::ContentLoading event (add, remove)
- ICoreWebView2_2::DOMContentLoaded event (add, remove)
- ICoreWebView2::NavigationCompleted event (add, remove)
- ICoreWebView2::FrameNavigationCompleted event (add, remove)
- ICoreWebView2Frame2::ContentLoading event (add, remove)
- ICoreWebView2Frame2::DOMContentLoaded event (add, remove)
- ICoreWebView2Frame2::NavigationCompleted event (add, remove)
The WebResourceRequested event allows the app to intercept and override all network requests in WebView2. The WebResourceResponseReceived event allows the app to monitor the request sent to and the response received from the network.
See also:
- ICoreWebView2::WebResourceRequested event (add, remove)
- ICoreWebView2_2::WebResourceResponseReceived event (add, remove)
The CustomSchemeRegistration allows registration of custom schemes in WebView2 so that the app can handle the WebResourceRequested event for requests to those custom scheme URLs and navigate the WebView2 to such URLs.
In WebView2, you can use the Client Certificate API to select the client certificate at the application level. This API allows you to:
- Display a UI to the user, if desired.
- Replace the default client certificate dialog prompt.
- Programmatically query the certificates.
- Select a certificate from the list to respond to the server, when WebView2 is making a request to an HTTP server that needs a client certificate for HTTP authentication.
- ICoreWebView2ClientCertificate interface
- ICoreWebView2_5::ClientCertificateRequested event (add, remove)
In WebView2, you can use the Server Certificate API to trust the server's TLS certificate at the application level. This way, your host app can render the page without prompting the user about the TLS error, or your host app can automatically cancel the request.
- CoreWebView2.ServerCertificateErrorDetected Event
- CoreWebView2.ClearServerCertificateErrorActionsAsync Method
- CoreWebView2.ServerCertificateErrorDetected Event
- CoreWebView2.ClearServerCertificateErrorActionsAsync Method
- ICoreWebView2_14::ServerCertificateErrorDetected event (add, remove)
- ICoreWebView2_14::ClearServerCertificateErrorActions method
iframes allow you to embed other webpages into your own webpage. In WebView2, you can:
- Find out when iframes are created.
- Find out when iframes are navigating.
- Allow bypassing x-frame options.
See also:
- Host/web object sharing, in this article.
- Using frames in WebView2 apps.
- ICoreWebView2Frame interface
- ICoreWebView2FrameInfo interface
- ICoreWebView2_4::FrameCreated event (add, remove)
Your app can handle basic authentication using the WebView2 control. Basic authentication is a specific authentication approach that's part of the HTTP protocol.
See also:
- CoreWebView2HttpRequestHeaders Class
- CoreWebView2.BasicAuthenticationRequested Event
- CoreWebView2BasicAuthenticationResponse Class
- CoreWebView2HttpHeadersCollectionIterator Class
- CoreWebView2HttpRequestHeaders Class
- CoreWebView2.BasicAuthenticationRequested Event
- CoreWebView2BasicAuthenticationResponse Class
- CoreWebView2HttpHeadersCollectionIterator Class
- ICoreWebView2HttpRequestHeaders interface
- ICoreWebView2_10::BasicAuthenticationRequested event (add, remove)
- ICoreWebView2BasicAuthenticationResponse interface
- ICoreWebView2HttpHeadersCollectionIterator interface
Use these APIs to set up the WebView2 rendering system if your host app doesn't use a UI framework. This rendering setup controls how WebView2 renders output into your host app, and how WebView2 handles input, focus, and accessibility.
-
UI framework - If you're using a UI framework for your app, you should use the WebView2 element that's provided by that UI framework, rather than using these APIs.
-
No UI framework, and not using Composition - If you're not using a UI framework for your app (for example, if you're using pure Win32 directly), or if your UI framework doesn't have a WebView2 element, then you need to create
CoreWebView2Controllerand render it into your app, using these APIs in this section. -
No UI framework, and using Composition - If your app UI is built using DirectComposition or Windows.UI.Composition, you should use
CoreWebView2CompositionControllerrather than using these APIs; see Rendering WebView2 using Composition, below.
- CoreWebView2Controller.CoreWebView2 Property
- CoreWebView2Controller.Close Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync Method
- CoreWebView2Controller.CoreWebView2 Property
- CoreWebView2Controller.Close Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync Method
- ICoreWebView2Controller::CoreWebView2 property (get)
- ICoreWebView2Controller::Close method
- ICoreWebView2Environment::CreateCoreWebView2Controller method
CoreWebView2Controller takes a parent HWND. The Bounds property sizes and positions the WebView2 relative to the parent HWND. The visibility of WebView2 can be toggled using IsVisible.
- ICoreWebView2Controller::Bounds property (get, put)
- ICoreWebView2Controller::IsVisible property (get, put)
WebView2 ZoomFactor is used to scale just the web content of the window. UI scaling is also updated when the user zooms the content by pressing Ctrl while rotating the mouse wheel.
- CoreWebView2Controller.ZoomFactor Property
- CoreWebView2Controller.ZoomFactorChanged Event
- CoreWebView2Controller.SetBoundsAndZoomFactor Method
Browser/gesture/zoom features:
- CoreWebView2Controller.ZoomFactor Property
- CoreWebView2Controller.ZoomFactorChanged Event
- CoreWebView2Controller.SetBoundsAndZoomFactor Method
Browser/gesture/zoom features:
- ICoreWebView2Controller::ZoomFactor property (get, put)
- ICoreWebView2Controller::ZoomFactorChanged event (add, remove)
- ICoreWebView2Controller::SetBoundsAndZoomFactor method
Browser/gesture/zoom features:
- ICoreWebView2Settings5::IsPinchZoomEnabled property (get, put)
- ICoreWebView2Settings::IsZoomControlEnabled property (get, put)
The RasterizationScale API scales all WebView2 UI including context menus, tooltip, and popups. The app can set whether the WebView2 should detect monitor scale changes and automatically update the RasterizationScale. BoundsMode is used to configure whether the Bounds property is interpreted as raw pixels, or DIPs (which need to be scaled by RasterizationScale).
- CoreWebView2Controller.BoundsMode Property
- CoreWebView2Controller.RasterizationScale Property
- CoreWebview2Controller.RasterizationScaleChanged Event
- CoreWebview2Controller.ShouldDetectMonitorScaleChanges Property
- CoreWebView2Controller.BoundsMode Property
- CoreWebView2Controller.RasterizationScale Property
- CoreWebview2Controller.RasterizationScaleChanged Event
- CoreWebview2Controller.ShouldDetectMonitorScaleChanges Property
- ICoreWebView2Controller3::BoundsMode property (get, put)
- ICoreWebView2Controller3::RasterizationScale property (get, put)
- ICoreWebView2Controller3::RasterizationScaleChanged event (add, remove)
- ICoreWebView2Controller3::ShouldDetectMonitorScaleChanges property (get, put)
The WebView2 control raises events to let the app know when the control gains focus or loses focus. For tabbing (pressing the Tab key), there's an API to move focus into WebView2 and an event for WebView2 to request the app to take focus back.
- CoreWebview2Controller.MoveFocus Method
- CoreWebview2Controller.MoveFocusRequested Event
- CoreWebview2Controller.GotFocus Event
- CoreWebview2Controller.LostFocus Event
- CoreWebview2Controller.MoveFocus Method
- CoreWebview2Controller.MoveFocusRequested Event
- CoreWebview2Controller.GotFocus Event
- CoreWebview2Controller.LostFocus Event
- ICoreWebview2Controller::MoveFocus method
- ICoreWebview2Controller::MoveFocusRequested event (add, remove)
- ICoreWebview2Controller::GotFocus event (add, remove)
- ICoreWebview2Controller::LostFocus event (add, remove)
WebView2 can be reparented to a different parent window handle (HWND). WebView2 also needs to be notified when the app's position on the screen has changed.
When WebView2 has focus, it directly receives input from the user. An app may want to intercept and handle certain accelerator key combinations, or disable the normal browser accelerator key behaviors.
- CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled Property
- CoreWebView2Controller.AcceleratorKeyPressed Event
- CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled Property
- CoreWebView2Controller.AcceleratorKeyPressed Event
- ICoreWebView2Settings3::AreBrowserAcceleratorKeysEnabled property (get, put)
- ICoreWebView2Controller::AcceleratorKeyPressed event (add, remove)
WebView2 can specify a default background color. The color can be any opaque color, or transparent. This color will be used if the HTML page doesn't set its own background color.
For composition-based WebView2 rendering, use CoreWebView2Environment to create a CoreWebView2CompositionController. CoreWebView2CompositionController provides the same APIs as CoreWebView2Controller, but also includes APIs for composition-based rendering.
- CoreWebView2CompositionController Class
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync Method
- CoreWebView2CompositionController Class
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync Method
- ICoreWebView2CompositionController interface
- ICoreWebView2Environment3::CreateCoreWebview2CompositionController method
WebView2 can connect its composition tree to an IDCompositionVisual, IDCompositionTarget, or Windows::UI::Composition::ContainerVisual.
Spatial input (mouse, touch, pen) is received by the application and must be sent to WebView2. WebView2 notifies the app when the cursor should be updated based on the mouse position.
-
CoreWebView2CompositionControllerClass -
CoreWebView2Environment.CreateCoreWebView2PointerInfo Method
-
CoreWebView2CompositionControllerClass -
CoreWebView2Environment.CreateCoreWebView2PointerInfo Method
-
CoreWebView2CompositionControllerinterface- ICoreWebView2CompositionController::Cursor property (get)
- ICoreWebView2CompositionController::CursorChanged event (add, remove)
- ICoreWebView2CompositionController::SystemCursorId property (get)
- ICoreWebView2CompositionController::SendMouseInput method
- ICoreWebView2CompositionController::SendPointerInput method
-
ICoreWebView2Environment3::CreateCoreWebView2PointerInfo method
Dragging from a WebView2 control to another application is supported by default. However, dragging to a WebView2 control requires that when the host app receives an IDropTarget event from the system, the host app must forward the event to the WebView2 control. Dragging to a WebView2 control includes drag-and-drop operations that are entirely within a WebView2 control.
Use the following APIs to forward IDropTarget events from the system to the WebView2 control.
- CoreWebView2CompositionController.DragLeave Method
- ICoreWebView2CompositionControllerInterop2.DragEnter Method
- ICoreWebView2CompositionControllerInterop2.DragLeave Method
- ICoreWebView2CompositionControllerInterop2.DragOver Method
- ICoreWebView2CompositionControllerInterop2.Drop Method
- ICoreWebView2CompositionController3::DragEnter method
- ICoreWebView2CompositionController3::DragLeave method
- ICoreWebView2CompositionController3::DragOver method
- ICoreWebView2CompositionController3::Drop method
By default, WebView2 will show up in the accessibility tree as a child of the parent HWND, for Win32/C++ apps. WebView2 provides API to better position the WebView2 content relative to other elements in the application.
Not applicable.
Not applicable.
- ICoreWebView2CompositionController2::AutomationProvider property (get)
- ICoreWebView2Environment4::GetAutomationProviderForWindow method
Manage the user data folder (UDF), which is a folder on the user's machine. The UDF contains data related to the host app and WebView2. WebView2 apps use user data folders to store browser data, such as cookies, permissions, and cached resources.
See also:
- CoreWebView2Environment.UserDataFolder Property
- CoreWebView2EnvironmentOptions.ExclusiveUserDataFolderAccess Property
- CoreWebView2Profile.ClearBrowsingDataAsync Method
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync Method
- CoreWebView2Environment.CreateCoreWebView2ControllerOptions Method
- CoreWebView2Environment.CreateCoreWebView2ControllerWithOptions Method
- CoreWebView2Environment.UserDataFolder Property
- CoreWebView2EnvironmentOptions.ExclusiveUserDataFolderAccess Property
- CoreWebView2Profile.ClearBrowsingDataAsync Method
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync(options) Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync Method
- CoreWebView2Environment.CreateCoreWebView2ControllerOptions Method
- ICoreWebView2Environment7::UserDataFolder property (get)
- ICoreWebView2EnvironmentOptions2::ExclusiveUserDataFolderAccess property (get, put)
- ICoreWebView2Profile2::ClearBrowsingData method
- ICoreWebView2Profile2::ClearBrowsingDataAll method
- ICoreWebView2Profile2::ClearBrowsingDataInTimeRange method
- ICoreWebView2Environment10::CreateCoreWebView2CompositionControllerWithOptions method
- ICoreWebView2Environment10::CreateCoreWebView2ControllerOptions method
- ICoreWebView2Environment10::CreateCoreWebView2ControllerWithOptions method
Manage multiple profiles under a single user data folder.
See also:
Create an options object that defines a profile:
Create a WebView2 control that uses the profile:
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync Method
Access and manipulate the profile:
Create an options object that defines a profile:
Create a WebView2 control that uses the profile:
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync(parentWindow) Method
- CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync(parentWindow, options) Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync(parentWindow, options) Method
- CoreWebView2Environment.CreateCoreWebView2ControllerAsync(parentWindow) Method
Access and manipulate the profile:
Create an options object that defines a profile:
Create a WebView2 control that uses the profile:
Access and manipulate the profile:
- ICoreWebView2_13::Profile property (get)
- ICoreWebView2Profile interface
- ICoreWebView2Profile2 interface - Methods to clear browsing data.
Analyze and debug performance, handle performance-related events, and manage memory usage to increase the responsiveness of your app.
- CoreWebView2.MemoryUsageTargetLevel Property
- CoreWebView2.TrySuspendAsync Method
- CoreWebView2.OpenTaskManagerWindow Method
- CoreWebView2.MemoryUsageTargetLevel Property
- CoreWebView2.TrySuspendAsync Method
- CoreWebView2.OpenTaskManagerWindow Method
- ICoreWebView2Experimental5::MemoryUsageTargetLevel property (get, put)
- ICoreWebView2_3::TrySuspend method
- ICoreWebView2_6::OpenTaskManagerWindow method
The Chrome DevTools Protocol provides APIs to instrument, inspect, debug, and profile Chromium-based browsers. The Chrome DevTools Protocol is the foundation for the Microsoft Edge DevTools. Use the Chrome DevTools Protocol for features that aren't implemented in the WebView2 platform.
See also:
Open:
Call:
- CoreWebView2.CallDevToolsProtocolMethodAsync Method
- CoreWebView2.CallDevToolsProtocolMethodForSessionAsync Method
Receiver:
Open:
Call:
- CoreWebView2.CallDevToolsProtocolMethodAsync Method
- CoreWebView2.CallDevToolsProtocolMethodForSessionAsync Method
Receiver:
Open:
- ICoreWebView2Settings::AreDevToolsEnabled property (get, put)
- ICoreWebView2::OpenDevToolsWindow method
Call:
- ICoreWebView2::CallDevToolsProtocolMethod method
- ICoreWebView2_11::CallDevToolsProtocolMethodForSession method
Receiver:
- Introduction to Microsoft Edge WebView2
- WebView2 API Reference - API Reference links for additional platforms and languages, such as WinRT/C++ (COM).