

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to call a JavaScript function from C++?
To call a JavaScript function from C++, generate a js file, which calls the function. The web page will load the JS and the function runs −
int callId = 0; void callFunction() { // the js file ofstream fout("generate.js"); fout << "caller(" << callId ++ << ", display);"; } // code
HTML
<html> <body> <script> var callId = 0; function caller(i, func) { if (callId < i ) { callId = i; func(); } } function display() { alert("my Function called"); } // load js script function loadScript(file) { var myId = "gh"; var e = document.getElementById(myId); if ( e != null ) e.parentNode.removeChild(e); var script = document.createElement("script"); script.myId = myId; script.src = file; document.body.appendChild(script); } window.setInterval(function() { //path to the js file loadScript("file:///path/generate.js"); }, 2000); </script> </body> </html>
- Related Questions & Answers
- How to Call a Lua function from C?
- How to call a JavaScript Function from Chrome Console?
- How to call a JavaScript function from an onClick event?
- How to call a JavaScript function from an onsubmit event?
- How to call a JavaScript function from an onmouseover event?
- How to call a JavaScript function from an onmouseout event?
- How to call a function in JavaScript?
- How to call a Java function inside JavaScript Function?
- How to delay a JavaScript function call using JavaScript?
- How to call a parent class function from derived class function in C++?
- How to call a JavaScript function on click?
- How to call a JavaScript function in HTML?
- How to call a parent window function from an iframe using JavaScript?
- JavaScript Function Call
- How to call jQuery function with JavaScript function?
Advertisements