简体   繁体   English

CefSharp 可以加载 html 内容吗?

[英]CefSharp possible to load html content?

I need to create a application which loads a html "template" file and parse them with current data values.我需要创建一个加载 html“模板”文件并使用当前数据值解析它们的应用程序。 So far no problemm but does anyone knows how to load the parsed html value into the cefsharp browser ?到目前为止没有问题,但有人知道如何将解析后的 html 值加载到 cefsharp 浏览器中吗?

I found some old topics here with an "loadHtml()" function.我在这里找到了一些带有“loadHtml()”函数的旧主题。 But this function isnt there anymore.但是这个功能已经不存在了。

Thanks in advance提前致谢

const string html = "<html><head><title>Test</title></head><body><h1>Html Encoded in URL!</h1></body></html>";
var base64EncodedHtml = Convert.ToBase64String(Encoding.UTF8.GetBytes(html));
browser.Load("data:text/html;base64," + base64EncodedHtml);

From the project wiki on github: Loading HTML/CSS/JavaScript/etc from disk/database/embedded resource/stream来自 github 上的项目 wiki: Loading HTML/CSS/JavaScript/etc from disk/database/embedded resource/stream

You need to add a using CefSharp;您需要添加一个using CefSharp; statement to your code to access the LoadHtml extensions methods.声明您的代码以访问LoadHtml扩展方法。

chromiumWebBrowser.LoadHtml(html);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM