Webkit.net 打开新选项卡和窗口 [英] Webkit.net opening new tabs and windows

查看:42
本文介绍了Webkit.net 打开新选项卡和窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 webkit.net 的上下文菜单轻松完成此操作:

I can easily do this by using webkit.net's context menu:

private void browser1_NewWindowRequest(object sender, WebKit.NewWindowRequestEventArgs e)
{
    ((Form1)MdiParent).AddTab(e.Url.ToString());
}

但是,对于提示新选项卡/窗口的 javascript 事件,newWindowrequesteventargs e 返回 null,我可以通过右键单击然后单击打开链接"来修复它,这实际上会在新选项卡或窗口中打开它(就像单击常规在新窗口中打开").对于仅提示新窗口超链接的按钮,以下仍然不起作用

However newWindowrequesteventargs e returns null for javascript events that prompt new tabs/windows, I can sort of fix it just by right clicking then clicking "open link" which does actually opens it in a new tab or window (as does clicking the regular "open in new window"). The following still does not work at all for buttons that prompt new windows only hyperlinks

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();单击打开链接"菜单项执行相同操作的控件.

This hypothetically would only work with links and not buttons, so I've been trying to look for the method done by the "Open Link" menu item in the control's native context menu I've look through the source of webkit.net but I cannot find anything, can someone help me out? I want to add webkitbrowser1.OpenLink(); to the control which would perform the same stuff clicking the "Open link" menu item would.

推荐答案

上下文菜单我已经解决了,在newwindowrequest事件中,你只要把e.Url.Tostring()获取当前url,你自己用添加选项卡或窗口方法以导航到它.仍然不确定 javascript

I have solve the context menu, in the newwindowrequest event, you just put e.Url.Tostring() to get the current url, and you use your own add tab or window method to navigate to it. Still not sure on javascript

这篇关于Webkit.net 打开新选项卡和窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆