interface IWebView2WebView3
Note
This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.
interface IWebView2WebView3
: public IWebView2WebView
Additional functionality implemented by the primary WebView object.
Summary
Members | Descriptions |
---|---|
Stop | Stop all navigations and pending resource fetches. |
add_NewWindowRequested | Add an event handler for the NewWindowRequested event. |
remove_NewWindowRequested | Remove an event handler previously added with add_NewWindowRequested. |
add_DocumentTitleChanged | Add an event handler for the DocumentTitleChanged event. |
remove_DocumentTitleChanged | Remove an event handler previously added with add_DocumentTitleChanged. |
get_DocumentTitle | The title for the current top level document. |
You can QueryInterface for this interface from the object that implements IWebView2WebView. See the IWebView2WebView interface for more details.
Members
Stop
Stop all navigations and pending resource fetches.
public HRESULT Stop()
add_NewWindowRequested
Add an event handler for the NewWindowRequested event.
public HRESULT add_NewWindowRequested(IWebView2NewWindowRequestedEventHandler * eventHandler,EventRegistrationToken * token)
Fires when content inside the WebView requested to open a new window, such as through window.open. The app can pass a target webview that will be considered the opened window.
// Register a handler for the NewWindowRequested event.
// This handler will defer the event, create a new app window, and then once the
// new window is ready, it'll provide that new window's WebView as the response to
// the request.
CHECK_FAILURE(m_webView->add_NewWindowRequested(
Callback<IWebView2NewWindowRequestedEventHandler>(
[this](IWebView2WebView* sender, IWebView2NewWindowRequestedEventArgs* args) {
wil::com_ptr<IWebView2Deferral> deferral;
CHECK_FAILURE(args->GetDeferral(&deferral));
auto newAppWindow = new AppWindow(L"");
newAppWindow->m_onWebViewFirstInitialized = [args, deferral, newAppWindow]() {
CHECK_FAILURE(args->put_NewWindow(newAppWindow->m_webView.get()));
CHECK_FAILURE(args->put_Handled(TRUE));
CHECK_FAILURE(deferral->Complete());
};
return S_OK;
})
.Get(),
nullptr));
remove_NewWindowRequested
Remove an event handler previously added with add_NewWindowRequested.
public HRESULT remove_NewWindowRequested(EventRegistrationToken token)
add_DocumentTitleChanged
Add an event handler for the DocumentTitleChanged event.
public HRESULT add_DocumentTitleChanged(IWebView2DocumentTitleChangedEventHandler * eventHandler,EventRegistrationToken * token)
The event fires when the DocumentTitle property of the WebView changes and may fire before or after the NavigationCompleted event.
// Register a handler for the DocumentTitleChanged event.
// This handler just announces the new title on the window's title bar.
CHECK_FAILURE(m_webView->add_DocumentTitleChanged(
Callback<IWebView2DocumentTitleChangedEventHandler>(
[this](IWebView2WebView3* sender, IUnknown* args) -> HRESULT {
wil::unique_cotaskmem_string title;
CHECK_FAILURE(sender->get_DocumentTitle(&title));
SetWindowText(m_appWindow->GetMainWindow(), title.get());
return S_OK;
})
.Get(),
&m_documentTitleChangedToken));
remove_DocumentTitleChanged
Remove an event handler previously added with add_DocumentTitleChanged.
public HRESULT remove_DocumentTitleChanged(EventRegistrationToken token)
get_DocumentTitle
The title for the current top level document.
public HRESULT get_DocumentTitle(LPWSTR * title)
If the document has no explicit title or is otherwise empty, a default that may or may not match the URI of the document will be used.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for