设置UA
/// <summary>
/// 初始化浏览器内核
/// </summary>
private void InitCefBrowser()
{
if (!Cef.IsInitialized)
{
//设置UA
CefSettings settings = new CefSettings();
settings.UserAgent = "TestUA";
Cef.Initialize(settings);
}
}
绑定JS:
c#:
public class HtmlLisnter
{
public void TestMessage(string msg)
{
MessageBox.Show(msg);
}
}
/// <summary>
/// 设置js
/// </summary>
private void SetJs()
{
HtmlLisnter htmlLisnter = new HtmlLisnter();
this.CefTest.RegisterJsObject("ExternalForWin", htmlLisnter, false);
}
JS:
function callback()
{
ExternalForWin.TestMessage('Test Success!');
}