@@ -31,9 +31,8 @@ m_webviewEventSource->add_NewWindowRequested(
3131 wil::unique_cotaskmem_string uri;
3232 CHECK_FAILURE(args->get_Uri(&uri));
3333
34- // Example usage of how the customer would use the window
35- // name to handle special cases such as "openInNewBrowser"
36- // which deviate from the normal handling of a new window.
34+ // Example usage of how the customer would use the window name to pass
35+ // additional context from their web content to their webview2 event handler.
3736 if (wcscmp(name.get(), L"openInNewBrowser") == 0)
3837 {
3938 ShellExecute(NULL, "open", uri.get(),
@@ -42,7 +41,7 @@ m_webviewEventSource->add_NewWindowRequested(
4241 }
4342 else
4443 {
45- HandleNormalNewWindow( );
44+ HandleNewWindow(args );
4645 }
4746 }
4847
@@ -60,17 +59,16 @@ void WebView_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEve
6059{
6160 string newWindowName = e.Name;
6261
63- // Example usage of how the customer would use the window
64- // name to handle special cases such as "openInNewBrowser"
65- // which deviate from the normal handling of a new window.
62+ // Example usage of how the customer would use the window name to pass
63+ // additional context from their web content to their webview2 event handler.
6664 if (newWindowName == "openInNewBrowser")
6765 {
6866 Process.Start(e.Uri);
6967 e.Handled = true;
7068 }
7169 else
7270 {
73- HandleNormalNewWindow( );
71+ HandleNewWindow(e );
7472 }
7573}
7674```
@@ -81,7 +79,15 @@ void WebView_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEve
8179/// This is a continuation of the `ICoreWebView2NewWindowRequestedEventArgs` interface.
8280[uuid(9bcea956-6e1f-43bc-bf02-0a360d73717b), object, pointer_default(unique)]
8381interface ICoreWebView2NewWindowRequestedEventArgs2 : ICoreWebView2NewWindowRequestedEventArgs {
84- /// Gets the name of the new window.
82+ /// Gets the name of the new window. This window can be created via `window.open(url, windowName)`,
83+ /// where the windowName parameter corresponds to `Name` property.
84+ /// If no windowName is passed to `window.open`, then the `Name` property
85+ /// will be set to an empty string. Additionally, if window is opened through other means,
86+ /// such as `<a target="windowName">...</a>` or `<iframe name="windowName>...</iframe>`,
87+ /// then the `Name` property will be set accordingly. In the case of target=_blank,
88+ /// the `Name` property will be an empty string.
89+ /// Opening a window via ctrl+clicking a link would result in the `Name` property
90+ /// being set to an empty string.
8591 [propget] HRESULT Name([out, retval] LPWSTR* value);
8692}
8793```
0 commit comments