更新时间:2023-09-01 12:56:04
退房:的证明了概念.NET System.Windows.Forms.WebBrowser模块的使用源$ C $ C
Check out: proof-of-concept of .NET System.Windows.Forms.WebBrowser module using source code
我的有关控制的经历给了我的视野,这个问题可以尝试在接下来的步骤来解决:
My experience about that controls has given me a vision that this issue can tried to be solved in next steps:
随时取消 NewWindow 一>事件
但不是所有的链接可以被缓存这样,所以我决定来解析所有的标签< A>
手动文件加载完成
but not all link can be cached this way, so I decided to parse all tags <a>
manually on Document Loading Completion
在一般情况下,这种控制是非常差,目前已经取得微软刻意。虽然有各地 Webrowser.Document.HtmlDocument功能强大的工具集和命名空间 MSHTML
in general, this control is very poor and has been made so by Microsoft deliberately. though there is powerful toolset around Webrowser.Document.HtmlDocument and namespace MSHTML
的它的使用的一个例子是的 HtmlElement.DomElement
an example of it's using is HtmlElement.DomElement
foreach(HtmlElement tag in webBrowser.Document.All)
{
switch (tag.TagName.ToUpper)
{
case "A":
{
tag.MouseUp += new HtmlElementEventHandler(link_MouseUp);
break;
}
}
}
void link_MouseUp(object sender, HtmlElementEventArgs e)
{
HtmlElement link = (HtmlElement)sender;
mshtml.HTMLAnchorElementClass a = (mshtml.HTMLAnchorElementClass)link.DomElement;
switch (e.MouseButtonsPressed)
{
case MouseButtons.Left:
{
if ((a.target != null && a.target.ToLower() == "_blank") ||
e.ShiftKeyPressed ||
e.MouseButtonsPressed == MouseButtons.Middle)
{
// add new tab
}
else
{
// open in current tab
}
break;
}
case MouseButtons.Right:
{
// show context menu
break;
}
}
}
查看更多在第一个环节,那就是主窗口的来源$ C $ C,有很多不同的手法在那里!
See more at the first link, that's the source code of main window, there are a lot of different manipulations there!