Note it here, you can check it when you need it in the future!
<HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio"><meta http-equiv="content-type" content="text/html;charset=gbk"><TITLE>HTML page, test JS calls to C functions</TITLE></HEAD><BODY> <input type="button" value="test JS calls to C++ without arguments (Window Binding)" onclick="javascript:testCallFunc()" /> <br/><hr /><br /> <input type="button" value="Test JS calls multi-parameter C++ function (Window Binding)" onclick="javascript: testCallFunc2()" /><input id="func2_input1" type="text" value="Input parameter 1 here" onclick=" if (this.value == 'Input parameter 1 here') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}" /><input id="func2_input2" type="text" value="Input parameter 2 here" onclick=" if (this.value == 'Input parameter 2 here') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}"/> <br /><hr /><br /> <input type="button" value="test, call C++ function to modify JS Window object properties (Window Binding)" onclick="javascript: testCallFunc3()" /><input id="func3_input" type="text" value="enter the value of the global variable here" onclick=" if (this.value == 'Input the value of the global variable here') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}" /> <br /><hr/><br /> <input type="button" value="test to get attributes set by C++ in JS Window object (Window Binding)" onclick="javascript:testGetGlobalVar()" /> <br /><hr /><br /> <input type="button" value="test JS calls multi-parameter C++ function (extended method)" onclick="javascript: alert('test JS calls multi-parameter C++ function (extended method)=>' + kagulaTest.myfunc(document.getElementById('func2_input1').value, document.getElementById('func2_input2').value))"/> <br /><hr /><br /></BODY></HTML><script> //http://www.w3schools.com/jsref/event_onclick.asp //document.write('Hello World!<br/>'); //test JS calls C++, function testCallFunc() { alert(window.myKagulaFunc()); } //Test JS calls C++ with two parameter functions function testCallFunc2() { var arg1 = document.getElementById("func2_input1").value; var arg2 = document.getElementById("func2_input2").value; alert(window.myKagulaFunc2(arg1,arg2)); //Return the "head and tail" string correctly. } function testCallFunc3() { var oldValue = window.myKagulaVal; var arg = document.getElementById("func3_input").value; window.myKagulaFunc3(arg); var newValue = window.myKagulaVal; alert("new value: " + newValue + "/r/nold value: " + oldValue); } //Test JS read variables set by C++ testGetGlobalVar() { alert(window.myKagulaVal); } //Test c++ to call JS function myFunction() { //document.getElementById("demo").style.color = "red"; alert("C++ calls JS test successfully!"); }</script>The above HTML page, a simple example of testing JS calls to C functions, is the entire content shared by the editor. I hope it can give you a reference and I hope you can support Wulin.com more.