File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,6 +98,9 @@ void MyApp::HandleHostedSites()
9898 })
9999 .Get(),
100100 nullptr));
101+ // Using FrameNavigationStarting event instead of NavigationStarting event of CoreWebViewFrame
102+ // to cover all possible nested iframes inside the hosted site as CoreWebViewFrame
103+ // object currently only support first level iframes in the top page.
101104 CHECK_FAILURE(m_webview->add_FrameNavigationStarting(
102105 Microsoft::WRL::Callback<ICoreWebView2NavigationStartingEventHandler >(
103106 [ this] (
@@ -164,13 +167,21 @@ void MyApp::HandleHostedSites()
164167 m_hostingSite = false;
165168 }
166169
170+ // Using FrameNavigationStarting event instead of NavigationStarting event of CoreWebViewFrame
171+ // to cover all possible nested iframes inside the hosted site as CoreWebViewFrame
172+ // object currently only support first level iframes in the top page.
167173 private void CoreWebView2_FrameNavigationStarting(CoreWebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs args)
168174 {
169175 if (IsTargetSite(args.Uri))
170176 {
171177 args.AdditionalAllowedFrameAncestors = myTrustedSite;
172178 }
173179 }
180+ private void HandleHostedSites()
181+ {
182+ webView.FrameCreated += CoreWebView2_FrameCreated;
183+ webView.FrameNavigationStarting += CoreWebView2_FrameNavigationStarting;
184+ }
174185```
175186
176187# API Details
You can’t perform that action at this time.
0 commit comments