谷歌内核,cef浏览器js代码返回到c#中操作
2019-12-18 本文已影响0人
孤傲小狼
源代码:
StringBuilder sb = new StringBuilder();
sb.AppendLine("function tempFunction() {");
sb.AppendLine(" return '10';");
sb.AppendLine("}");
sb.AppendLine("document.getElementById('J_SubmitStatic').onclick=tempFunction();");
var task = frame.EvaluateScriptAsync(sb.ToString());
task.ContinueWith(t =>
{
if (!t.IsFaulted)
{
var response = t.Result;
if (response.Success == true)
{
MessageBox.Show(response.Result.ToString());
}
}
}, TaskScheduler.FromCurrentSynchronizationContext());