进一步停止 link 在 Web 浏览器控件内导航 [WPF]
Stop further link navigating inside web browser control [WPF]
您好,WinForms 中有类似 AllowNavigation 的东西吗?
我的搜索没有产生任何令人满意的结果。
基本上我试图在新 wpf window 中打开一个网页并阻止用户单击该网页上的随机链接并进一步导航。
用
看到了一些东西
void browser1_Navigating(object sender, NavigatingCancelEventArgs e)
{
e.Cancel = true;
}
其余代码为:
public Popup_webpage(string ime)
{
InitializeComponent();
browser1.LoadCompleted += browser1_LoadCompleted;
browser1.Navigating += browser1_Navigating;
string uri = "www.google.com"
browser1.Navigate(new Uri(uri, UriKind.Absolute));
}
void browser1_LoadCompleted(object sender, NavigationEventArgs e)
{
browser1.Visibility = Visibility.Visible;
}
但它只是让我的网页无法显示?
谢谢
试试这个:
加载页面后,分配 browser_Navigating 事件处理程序。
public Popup_webpage(string ime)
{
InitializeComponent();
browser1.LoadCompleted += browser1_LoadCompleted;
string uri = "www.google.com"
browser1.Navigate(new Uri(uri, UriKind.Absolute));
browser1.Navigating += browser1_Navigating;
}
void browser1_LoadCompleted(object sender, NavigationEventArgs e)
{
browser1.Visibility = Visibility.Visible;
}
void browser1_Navigating(object sender, NavigatingCancelEventArgs e)
{
e.Cancel = true;
}
您好,WinForms 中有类似 AllowNavigation 的东西吗?
我的搜索没有产生任何令人满意的结果。 基本上我试图在新 wpf window 中打开一个网页并阻止用户单击该网页上的随机链接并进一步导航。
用
看到了一些东西void browser1_Navigating(object sender, NavigatingCancelEventArgs e)
{
e.Cancel = true;
}
其余代码为:
public Popup_webpage(string ime)
{
InitializeComponent();
browser1.LoadCompleted += browser1_LoadCompleted;
browser1.Navigating += browser1_Navigating;
string uri = "www.google.com"
browser1.Navigate(new Uri(uri, UriKind.Absolute));
}
void browser1_LoadCompleted(object sender, NavigationEventArgs e)
{
browser1.Visibility = Visibility.Visible;
}
但它只是让我的网页无法显示?
谢谢
试试这个:
加载页面后,分配 browser_Navigating 事件处理程序。
public Popup_webpage(string ime)
{
InitializeComponent();
browser1.LoadCompleted += browser1_LoadCompleted;
string uri = "www.google.com"
browser1.Navigate(new Uri(uri, UriKind.Absolute));
browser1.Navigating += browser1_Navigating;
}
void browser1_LoadCompleted(object sender, NavigationEventArgs e)
{
browser1.Visibility = Visibility.Visible;
}
void browser1_Navigating(object sender, NavigatingCancelEventArgs e)
{
e.Cancel = true;
}