.NET/WPF

WPF에서 WebBrowser 컨트롤 스크립트 오류 없애기

언제나휴일 2020. 7. 31. 16:53
반응형

 

MainWindows.xaml

<Window x:Class="WPF_WebBrowser_컨트롤_스크립트_오류_방지.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:WPF_WebBrowser_컨트롤_스크립트_오류_방지"
        mc:Ignorable="d"        
        Loaded="Window_Loaded"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <WindowsFormsHost Name="wfh" />
    </Grid>
</Window>

MainWindow.cs

using System.Windows;

namespace WPF_WebBrowser_컨트롤_스크립트_오류_방지
{
    /// <summary>
    /// MainWindow.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();
            wfh.Child = wb;
            wb.ScriptErrorsSuppressed = true;
            wb.Navigate("http://ehpub.co.kr");
        }
    }
}
반응형