當前位置:編程學習大全網 - 網站源碼 - C# 的cefsharp 裏的ChromiumWebBrowser執行js

C# 的cefsharp 裏的ChromiumWebBrowser執行js

具體調用:

IBrowser browser = this._browser.GetBrowser();

if (browser.HasDocument)

{

IFrame mainFrame = browser.MainFrame;

var js = "var f= function A(){ return $('img',$('#"+id+"'));}; f();";

var task = mainFrame.EvaluateScriptAsync(js, null);// "(function() { var body = document.body, html = document.documentElement; return Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); })();", null);

//執行腳本

//browser.MainFrame.ExecuteJavaScriptAsync("document.getElementById('testid').click();");

//browser.MainFrame.ExecuteJavaScriptAsync("document.getElementById('testid2').value='123'");

task.ContinueWith(t =>

{

if (!t.IsFaulted)

{//返回結果

var response = t.Result;

var result = response.Success ? (response.Result ? "null") : response.Message;

//html = result.ToString();

}

}, TaskScheduler.FromCurrentSynchronizationContext());

}

  • 上一篇:H5遊戲制作怎麽實現,遊戲都有哪些分類和玩法?
  • 下一篇:任天堂中文官網是什麽?
  • copyright 2024編程學習大全網