When integrating JavaScript code into a WebBrowser Control in my WPF
App, I encountered an issue with the function Object.freeze()
, resulting in an error when running the application.
Here is how my .xaml file with the WebBrowser control looks:
<Window x:Class="TestWPFApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestWPFApp"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WebBrowser x:Name="ProgressBarWeb" HorizontalAlignment="Left" Height="300" VerticalAlignment="Top" Width="300"/>
</Grid>
</Window>
The HTML and JavaScript code is injected using the NavigateToString()
method:
public MainWindow()
{
InitializeComponent();
//Example JavaScript code
var html = "<html><head><script>" +
"var platformtypes = {"Attr1": 0, "Attr2": 1};" +
"Object.freeze(platformtypes);" +
"</script></head><body></body></html>"
ProgressBarWeb.NavigateToString(html);
}
My current questions are:
- Which interpreter does Visual Studio 2017 use for interpreting JavaScript code?
- Is it possible to change or update the interpreter being used?
- Or am I overlooking something else entirely?