Shawn Ramirez
Shawn Ramirez

Reputation: 833

Viewing js enabled page in UWP Webview

Hi I am trying to open a webpage and display it's contents within a UWP Webview.

I am presuming that I doing something wrong as the topic is quite new to me.

My main routine:

WebViewSettings webSettings = WebviewControll.Settings;
webSettings.IsJavaScriptEnabled = true;
WebviewControll.Navigate(new Uri("https://threejs.org/examples/webgl_geometry_cube.html", UriKind.Absolute));

saw some comments about enabling with my Package.appxmanifest:

  <uap:ApplicationContentUriRules>
    <uap:Rule Match="ms-appx-web:///Web/App.html" WindowsRuntimeAccess="all" Type="include"/>
  </uap:ApplicationContentUriRules>
</Application>

my XAML:

<Grid>
    <WebView x:Name="WebviewControll" Height="auto" Width="auto"  >
    </WebView>

</Grid>

expected Result:

enter image description here

actual: enter image description here

Upvotes: 0

Views: 597

Answers (1)

Roy Li - MSFT
Roy Li - MSFT

Reputation: 8666

Please take a look at the new WebView2 control. Use the WebView2 control instead of the old WebView control. Using the WebView2 control, I could see the html page is shown correctly.

To use the WebView2 in your UWP app, you will need to install the Microsoft.Web.WebView2 and Microsoft.UI.Xaml-2.8 NuGet package.

Use it like the old WebView:

<control:WebView2 x:Name="wv2" Source="https://threejs.org/examples/webgl_geometry_cube.html"/>

For more information, please check this document:Get started with WebView2 in WinUI 2 (UWP) apps (public preview)

Upvotes: 1

Related Questions