WinForms WebBrowser control's JavaScript execution context

330 Views Asked by At

I am using the WinForms WebBrowser control in my C# application and I can interact with the JS code on the web page by setting a COM class in the ObjectForScripting property of the control.

Is it possible to get the JavaScriptContext object from the web browser control that I can use with the ChakraCore API?

1

There are 1 best solutions below

1
On

No sir, ChakraCore is part of the Microsoft Edge JavaScript engine. It is literally a separate engine. The web browser control uses IE's engine. Although admittedly it doesn't help that the dev team at MS called The MS Edge Engine Chakra when they were calling the engine from IE 9 forward as Chakra also.

Anyway if you want to use/embed the ChakraCore engine from C# they did create a getting started page. I will link it here.

The API for the winforms Webbrowser control Engine is here. The is a wrapper around the COM API. If you need to get to the COM api to do advanced things, you will need MSHTML, which you add as a COM reference to Microsoft Html Object library. The reference for MSHTML is here.