C#의 WinRT 응용 프로그램에는 로컬 HTML 파일을 여는 webview가 포함 된 설정에 대한 userControl이 있습니다. 나는 네이티브 webbrowser를 시작하는 javascript 코드로이 html 파일에 대한 링크를 가로 챕니다. 그렇게하면 네이티브 웹 브라우저가 링크를 올바르게 표시하지만 '액세스 위반'예외가 발생하면 내 응용 프로그램이 동시에 중단됩니다. 여기 응용 프로그램에서 기본 웹 브라우저를 실행할 때 액세스 위반 예외
내 UserControl을 코드입니다 :public sealed partial class SimpleSettingsNarrow : UserControl
{
public SimpleSettingsNarrow()
{
this.InitializeComponent();
}
private void ConditionWB_Loaded_1(object sender, RoutedEventArgs e)
{
ConditionWB.ScriptNotify += ConditionWB_ScriptNotify;
ConditionWB.AllowedScriptNotifyUris = WebView.AnyScriptNotifyUri;
ConditionWB.Navigate(new Uri("ms-appx-web:///Assets/testWebview.html"));
}
private async void ConditionWB_ScriptNotify(object sender, NotifyEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri(e.Value));
}
}
그리고 여기 XAML 코드 :
<UserControl
x:Class="MyNameSpace.SimpleSettingsNarrow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyNameSpace"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="768"
d:DesignWidth="692">
<UserControl.Resources>
</UserControl.Resources>
<Border BorderBrush="Black" BorderThickness="1,0,0,0">
<Grid Background="White" VerticalAlignment="Stretch">
<!-- Root grid definition -->
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Header area for panel -->
<Grid Background="White" Grid.Row="0">
<Grid Margin="40,32,17,13">
<Grid.Transitions>
<TransitionCollection>
<EntranceThemeTransition FromHorizontalOffset="50" />
</TransitionCollection>
</Grid.Transitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Margin="10,0,0,0" Grid.Column="1" FontFamily="Segoe UI" FontWeight="Normal" FontSize="24.6667" Text="Déclaration de confidentialité" Foreground="Black" TextWrapping="Wrap" HorizontalAlignment="Left" />
</Grid>
</Grid>
<ScrollViewer Grid.Row="1" Margin="20,20,0,20" Padding="0,0,20,0">
<WebView x:Name="ConditionWB" Loaded="ConditionWB_Loaded_1"></WebView>
</ScrollViewer>
</Grid>
</Border>
</UserControl>
그리고 testWebview.html 파일에는 다음이 포함
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
test
<a href="javascript:window.external.notify('http://www.google.fr')">google</a>
</body>
</html>
당신을 수행 왜 이런 식으로 충돌하는지 아십니까?
고마워요.