简体   繁体   English

C ++-在浏览器(IE 11和Edge)中执行JavaScript的库

[英]C++ - Library to execute JavaScript in browser (IE 11 and Edge)

I would like to know if the following is feasible in C++, and if so, what library / api would be required: 我想知道以下内容在C ++中是否可行,如果可以,则需要什么库/ api:

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. 我想从我的C ++代码(IE11或Edge)启动浏览器会话,并从C ++代码在浏览器中执行一些JavaScript。 For example, launch https://stackoverflow.com and when users click on a button from my C++ GUI, display a JavaScript alert message. 例如,启动https://stackoverflow.com,然后当用户在我的C ++ GUI中单击按钮时,显示JavaScript警报消息。

Thanks for your help 谢谢你的帮助

Take a look at the "chromium embedded framework", google it to find it. 看看“铬嵌入式框架”,在Google上找到它。 This is not Microsoft stuff but who cares. 这不是微软的东西,而是谁在乎。

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. 为了澄清–您的C ++代码将需要以适合您的环境的方式启动浏览器对象,然后向其提供包含适当的<script>标记的HTML块。 The browser instance, not your C++ code, is then responsible for "doing the right thing" from that point forward. 从那时起,浏览器实例而不是您的C ++代码将负责“做正确的事”。

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: 您将需要启动与您的浏览器关联的进程,并为其提供一些初始化标志(例如,运行诸如以下的shell脚本):

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 无论如何,您可能需要研究更多有关EmscriptenCheerp的信息 ,它们是使您能够编写C ++代码并在浏览器中以Javascript本地运行的工具(通过Asm.js或Web Assembly)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM