我可以通过使用 webkit.net 的上下文菜单轻松做到这一点:
private void browser1_NewWindowRequest(object sender, WebKit.NewWindowRequestEventArgs e)
{
((Form1)MdiParent).AddTab(e.Url.ToString());
}
但是 newWindowrequesteventargs e 对于提示新选项卡/窗口的 javascript 事件返回 null,我可以通过右键单击然后单击“打开链接”来修复它,这实际上在新选项卡或窗口中打开它(就像单击常规“打开在新窗口中”)。 对于仅提示新窗口超链接的按钮,以下内容仍然不起作用
private void browser1_NewWindowRequest(object sender, WebKit.NewWindowRequestEventArgs e)
{
if (e.Url.ToString() != null)
{
((Form1)MdiParent).AddTab(e.Url.ToString());
}
else
{
//I just need to stimulate the mouse right clicking and then left clicking for this to work but this still does not work for buttons, how can I get the link from the element the mouse is over?
}
}
这假设只适用于链接而不是按钮,所以我一直在尝试寻找由控件的本机上下文菜单中的“打开链接”菜单项完成的方法我已经查看了 webkit.net 的源代码,但我找不到任何东西,有人可以帮我吗? 我想添加 webkitbrowser1.OpenLink(); 单击“打开链接”菜单项将执行相同操作的控件。