Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

JavaScript Execution

softoille@gmail.com edited this page Nov 29, 2019 · 1 revision

Frame handling allows developers to have access to the application browser and frames (iframe) objects, and with that JavaScript methods defined in the renderer can be executed from the browser.

To do that easily, a static helper class is provided - CefSharp FrameHanlder or CefGlue FrameHandler.

There are 3 methods provided:

  • GetMainFrame
  • GetFrame - requires the name of the frame as parameter.
  • GetBrowser

To get the frame name, the developer will have to declare that in the iframe object.

  <iframe id="demoframe" name="alldemoframe" .. />
  </div>

Executing JavaScript with CefSharp Apps

  IFrame frame = FrameHandler.GetFrame(frameName);
  frame.ExecuteJavaScriptAsync(script);

Evaluating JavaScript with CefSharp Apps

  IFrame frame = FrameHandler.GetFrame(frameName);
  Task<JavascriptResponse> javascriptResponse = frame.EvaluateScriptAsync(script);
  javascriptResponse.Wait();

Executing JavaScript with CefGlue Apps

IFrame frame = FrameHandler.GetFrame(frameName);
frame.ExecuteJavaScript(script, null, 0);

For demo please see CefSharp JavaScript | CefSharp Controller and CefGlue JavaScript | CefGlue Controller.

Demo Page:

Clone this wiki locally