通过使用webkit.net的上下文菜单,我可以轻松地做到这一点:
private void browser1_NewWindowRequest(object sender, WebKit.NewWindowRequestEventArgs e)
{
((Form1)MdiParent).AddTab(e.Url.ToString());
}但是,对于提示新选项卡/窗口的javascript事件,newWindowrequesteventargs e返回null,我只需右键单击"open link“就可以修复它,它实际上会在一个新的选项卡或窗口中打开它(单击常规的”在新窗口中打开“)。以下仍然不适用于只提示新窗口的按钮--仅超链接
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?
}
}这个假设只适用于链接,而不是按钮,因此我一直在尝试寻找控件的本机上下文菜单中的"Open“菜单项所做的方法,我已经查看了webkit.net的源代码,但找不到任何东西,有人能帮我吗?,我想添加webkitbrowser1.OpenLink();到控件中,它将执行与单击”打开链接“菜单项的操作相同的操作。。
发布于 2013-08-04 20:46:30
我已经解决了上下文菜单,在newwindowrequest请求事件中,您只需放置e.Url.Tostring()来获取当前的url,然后使用自己的add选项卡或window方法导航到它。对javascript仍不确定
https://stackoverflow.com/questions/17909425
复制相似问题