如何让webbrowser控件支持Html5
答案:2 悬赏:20 手机版
解决时间 2021-02-21 21:18
- 提问者网友:捧腹剧
- 2021-02-21 05:34
如何让webbrowser控件支持Html5
最佳答案
- 五星知识达人网友:像个废品
- 2021-02-21 06:23
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xilium.CefGlue;
namespace Xilium.CefGlue.WindowsForms
{
public class BsLifeSpanHandler : CefLifeSpanHandler
{
private CefWebClient bClient;
public BsLifeSpanHandler(CefWebClient bc)
{
bClient = bc;
}
protected override void OnAfterCreated(Xilium.CefGlue.CefBrowser browser)
{
base.OnAfterCreated(browser);
bClient.Created(browser);
}
}
}
然后打开CefWebClient.cs文件,添加声明
private readonly CefDownloadHandler downloadHandler;
在构造函数中加入
downloadHandler = new BsDownloadHandler();
然后添加一个方法名在文档末尾
protected override CefDownloadHandler GetDownloadHandler()
{
return downloadHandler;
}
这样就可以实现点击文档或附件自动弹出下载对话框了,同时又支持javascript和C#的调用。也就能支持绝大多数的客户端开发了。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xilium.CefGlue;
namespace Xilium.CefGlue.WindowsForms
{
public class BsLifeSpanHandler : CefLifeSpanHandler
{
private CefWebClient bClient;
public BsLifeSpanHandler(CefWebClient bc)
{
bClient = bc;
}
protected override void OnAfterCreated(Xilium.CefGlue.CefBrowser browser)
{
base.OnAfterCreated(browser);
bClient.Created(browser);
}
}
}
然后打开CefWebClient.cs文件,添加声明
private readonly CefDownloadHandler downloadHandler;
在构造函数中加入
downloadHandler = new BsDownloadHandler();
然后添加一个方法名在文档末尾
protected override CefDownloadHandler GetDownloadHandler()
{
return downloadHandler;
}
这样就可以实现点击文档或附件自动弹出下载对话框了,同时又支持javascript和C#的调用。也就能支持绝大多数的客户端开发了。
全部回答
- 1楼网友:你可爱的野爹
- 2021-02-21 07:40
代码如下:
using system;using system.collections.generic;using system.linq;using system.text;using system.threading.tasks;using xilium.cefglue; namespace xilium.cefglue.windowsforms{ public class bslifespanhandler : ceflifespanhandler { private cefwebclient bclient; public bslifespanhandler(cefwebclient bc) { bclient = bc; } protected override void onaftercreated(xilium.cefglue.cefbrowser browser) { base.onaftercreated(browser); bclient.created(browser); } }}
然后打开cefwebclient.cs文件,添加声明
1
private readonly cefdownloadhandler downloadhandler;
在构造函数中加入
1
downloadhandler = new bsdownloadhandler();
然后添加一个方法名在文档末尾
protected override cefdownloadhandler getdownloadhandler() { return downloadhandler; }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯