vb.net 检测是否在 Webbrowser 控件中单击了链接 [英] vb.net Detect if a link is clicked in Webbrowser control
本文介绍了vb.net 检测是否在 Webbrowser 控件中单击了链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 VB.NET 2005 中的标准 Windows 窗体上有一个 Webbrowser 控件.我只想检测何时有人单击 Webbrowser 控件内的链接,它只是告诉我他们单击了什么,或者它试图去哪里,然后取消进程.
I have a Webbrowser control on a standard windows form in VB.NET 2005. I just want to detect when someone clicks a link inside the Webbrowser control it just tells me what they clicked on, or where its trying to go, then cancel the process.
我试过把..
MsgBox(e.Url)
e.Cancel = True
在 WebBrowser1_Navigating EVENT 内部,但没有任何作用.有人可以帮忙吗?
Inside of the WebBrowser1_Navigating EVENT, but that does nothing. Can anyone help?
推荐答案
这就是问题所在:
MsgBox(e.Url)
MsgBox(e.Url)
试试这个:
MsgBox(e.Url.ToString())
MsgBox(e.Url.ToString())
Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
If MsgBox("You are trying to go to:" & vbCr & e.Url.ToString() & vbCr & "Cancel Navigate?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
e.Cancel = True
End If
End Sub
这篇关于vb.net 检测是否在 Webbrowser 控件中单击了链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文