1

I would like to know if the following is feasible in C++, and if so, what library / api would be required:

I want to launch a browser session from my C++ code (IE11 or Edge), and execute some JavaScript in the broswer from the C++ code. For example, launch https://stackoverflow.com and when users click on a button from my C++ GUI, display a JavaScript alert message.

Thanks for your help

MiniG34
  • 312
  • 2
  • 12

3 Answers3

0

Take a look at the "chromium embedded framework", google it to find it. This is not Microsoft stuff but who cares.

Codebeat
  • 6,501
  • 6
  • 57
  • 99
  • Also, [Puppeteer](https://developers.google.com/web/tools/puppeteer/), and [Chrome DevTools automation API](https://chromedevtools.github.io/devtools-protocol/). – Wyck Jan 14 '19 at 18:19
0

To clarify – your C++ code will need to launch a browser-object in a manner appropriate to your environment, and then feed it a block of HTML which includes appropriate <script> tags. The browser instance, not your C++ code, is then responsible for "doing the right thing" from that point forward.

Mike Robinson
  • 8,490
  • 5
  • 28
  • 41
0

Actually launching a browser depends on your operative system. You will need to launch a process associated with your browser, providing it some initialization flags (for example running a shell script like:

open -a "Google Chrome" index.html

In any case, you may want to investigate a little more about Emscripten or Cheerp that are tools that allow you to write C++ code and running it on the browser natively in Javascript (via Asm.js or Web Assembly