CWebView Class Options  
 

When creating or attaching a WebView instance, a set of options can be specified that control its behavior. These options are defined as a collection of bitmask flags that can be combined together. The dwOptions parameter passed to methods such as Create or Attach may include one or more of these values.

Option Constants

Name Description
WEBVIEW_OPTION_ENABLE_ACCELERATORS Enables support for browser accelerator keys such as function keys (F1 for help, F5 for refresh, etc.) and standard navigation shortcuts. With this option enabled, the WebView responds to built-in key combinations in the same way a full browser does. Disabling it prevents end users from triggering those behaviors, which may be desirable in kiosk or custom application scenarios where you want to restrict keyboard input to only what your application explicitly supports.
WEBVIEW_OPTION_ENABLE_CONTEXT_MENU Enables the default right-click context menu provided by the browser. This menu exposes commands such as Back, Forward, Reload, and View Source. In an embedded control, this may not always be appropriate since it can expose functionality you do not want available to users. Disabling this option suppresses the default context menu entirely, leaving you free to implement your own context handling if needed.
WEBVIEW_OPTION_ENABLE_STATUSBAR Shows the built-in status bar, which normally appears at the bottom left of the control when hovering over a link. It provides basic feedback about navigation targets but has no interactive features. In a minimal UI, you may prefer to disable this so the embedded control presents only the rendered page without browser chrome. Developers can still query navigation state programmatically regardless of this setting.
WEBVIEW_OPTION_ENABLE_ZOOM_CONTROL Enables zoom support through keyboard and mouse input (Ctrl+Plus, Ctrl+Minus, Ctrl+Mouse Wheel). With this enabled, end users can adjust the document's scaling factor directly. When disabled, zooming is locked at 100%, ensuring that the page is always displayed at its natural size. This can be useful in applications where layout fidelity is important and user scaling could cause unexpected clipping or misalignment.
WEBVIEW_OPTION_ENABLE_AUDIO Enables audio playback within the WebView. When this option is disabled, the control is effectively muted and no sound is produced, regardless of the page content. Applications that need to enforce silent operation, such as monitoring dashboards, may want to leave this option disabled. This flag maps to the runtime's muting APIs and can be toggled dynamically after creation.
WEBVIEW_OPTION_ENABLE_AUTOFILL Enables the use of autofill for HTML forms. When enabled, the control can suggest previously entered values for form fields such as names, addresses, or other personal data. Disabling this option prevents the runtime from remembering or suggesting values, which is often preferable in scenarios where privacy is a concern or where data entry should always be manual.
WEBVIEW_OPTION_ENABLE_PASSWORD_AUTOSAVE Enables automatic saving of credentials in the runtime's password store. When this option is set, the control prompts to save usernames and passwords entered in forms, making them available for later autofill. While convenient for end users, applications embedding the control may choose to disable this to avoid storing sensitive information on the client system, particularly in enterprise or shared environments.
WEBVIEW_OPTION_ENABLE_PRIVACY Enables the equivalent of InPrivate browsing in Microsoft Edge or Incognito mode in Google Chrome. If this option is specified, the user profile is not persisted beyond the current session. Browsing and search history will not be preserved, all cookies are temporary, data entered in form fields will not be saved and passwords will not be stored. Any general location information used by the browser is cleared when the instance is closed. This option can only be specified when the browser instance is created or attached to a window. You cannot enable privacy mode after a browser session has started.
WEBVIEW_OPTION_ENABLE_SCRIPTING Enables JavaScript execution within the WebView. Nearly all modern websites depend on JavaScript, so disabling this option will significantly limit what pages can display or function correctly. However, for controlled content where scripting is unnecessary or potentially unsafe, disabling this can enforce a higher level of security and prevent active content from running. Some other options, such as enabling dialogs shown in the browser or receiving messages from the web application requires scripting to be enabled. If your application is only displaying local, static HTML content then you may not need to enable this option.
WEBVIEW_OPTION_ENABLE_DIALOGS Enables support for default script dialogs such as alert, confirm, and prompt. If disabled, those dialogs are suppressed and scripts attempting to display them will fail silently. This prevents unexpected modal UI from appearing in your application, but may also break sites that rely on these dialogs for basic interaction. If you enable scripting, it is recommended that you enable this option as well.
WEBVIEW_OPTION_ENABLE_DEVTOOLS Enables the integrated Developer Tools (DevTools) interface. When enabled, users can press standard shortcuts (such as F12) or use the context menu to open the DevTools window and inspect the page. For production applications, you may want to disable this to prevent end users from inspecting or modifying content. During development or debugging, enabling it provides the same diagnostic features found in Microsoft Edge.
WEBVIEW_OPTION_ENABLE_NEW_WINDOWS Enables the creation of new popup windows by scripts and/or support the creation of new browser windows (for example, if a link target is "_blank"). By default, navigations that would open a new window are redirected internally so the new page is displayed within the same browser window. Note that if you permit the creation of new popup windows, it can shift focus away from your main browser window. There is no mechanism in the API to enumerate the child popup windows and they are independent of the window attached to the browser.
WEBVIEW_OPTION_ENABLE_MESSAGES Enables communication between the web page and the host application through the window.chrome.webview.postMessage API. This allows JavaScript running in the page to send messages back to your application, enabling advanced integration scenarios. If disabled, such messages are blocked and the corresponding events will never occur in your host code. This is commonly enabled when embedding custom HTML user interfaces that need to exchange data with the native application.
WEBVIEW_OPTION_ENABLE_EXTERNAL_DROP Enables the WebView to accept external file drops, such as dragging and dropping a file from Windows Explorer into the control. If disabled, drop operations are ignored and the page cannot receive file input in this way. Applications that want to support drag-and-drop uploads or similar features can enable this option, but in contexts where security is important it may be best to disable it to prevent accidental or malicious file submission. Accepting dropped files requires scripting to be enabled.
WEBVIEW_OPTION_RESTRICT_NAVIGATION Restricts navigation after the initial page has loaded. Attempts to navigate beyond this initial page will automatically be canceled when this option is specified. This is useful for scenarios like embedded help viewers, dashboards, or authentication windows where you want to confine the user to a specific site or document. The restriction applies to both user-initiated actions such as clicking links and programmatically navigating to a new URL.
WEBVIEW_OPTION_RESTRICT_DOWNLOADS Prevents the browser from downloading files. Attempts to download a file will be immediately canceled and no download UI will be displayed to the user. Normally, downloads are permitted and files will be stored in the current user's Downloads folder. If you wish to selectively prevent certain types of downloads, you can monitor the download events and decide individually whether the file should be downloaded based on the name, extension or location.
WEBVIEW_OPTION_EXCLUSIVE_PROFILE Requires exclusive use of the default user profile stored in the data folder selected when the browser instances is created. If this option is enabled, the browser will attempt to obtain an exclusive lock on the profile which stores the current user's cached pages, browser history, cookies and passwords. Normally this session data can be shared with other processes, but this option ensures that only the current process may access it while the browser session is active. If another browser session is sharing the same data, the creation process will fail. This option can only be specified when the browser instance is created or attached to a window.
WEBVIEW_OPTION_TRANSPARENT_BACKGROUND Configures the WebView to render with a transparent background rather than an opaque surface. This allows the host application to blend the browser content with custom UI elements or backgrounds. It is particularly useful for overlay scenarios, custom skins, or when compositing content with layered windows. Developers should be aware that transparent rendering may affect performance on some systems and should test carefully in their application's UI context.

Remarks

Most of these options can be toggled dynamically at runtime using the SetOption method, although some are only effective when set at creation time. Options are applied by mapping directly to the underlying WebView2 runtime's settings and may depend on a minimum runtime version. If an option is not supported by the installed version of the WebView2 runtime, calls to enable it will fail silently.

The WEBVIEW_OPTION_ENABLE_DEFAULT macro combines the most commonly used options, including accelerator keys, context menu, status bar, zoom control, audio, scripting, and dialogs. This provides a browser-like experience suitable for most applications. Developers with stricter requirements for security or a highly customized UI should select individual flags instead of relying on the defaults. For applications in managed environments, kiosk systems, or where privacy is a concern, it is recommended to only enable those specific features which are required for normal operation.

The WEBVIEW_OPTION_ENABLE_PRIVACY option causes the WebView2 instance to create a unique, temporary user data folder with a new user profile. It will not have access to the browsing history, saved form data or passwords for any other instance. When the browser is closed or detached from its host window, that temporary profile will be automatically deleted. There can be a minor performance cost related to creating and deleting these temporary profiles, particularly if a large amount of data has been cached during the session.

As with private browsing using a web browser like Microsoft Edge or Google Chrome, enabling privacy does not prevent an employer or Internet provider from being able to monitor your activity. Websites can still track your behavior, particularly if scripting is enabled because most sites use scripts as part of their analytics tracking. Private browsing will block third-party cookies by default, but otherwise permits the use of cookies during the session. Any data stored using the HTML5 web storage APIs will also be deleted when a private session ends.

See Also