HTML page to test a simple example of JS calling the C function
- 2021-07-09 06:53:30
- OfStack
Remember 1 here, and you can check it when you want to use 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 Right C Call of function </TITLE>
</HEAD>
<BODY>
<input type="button" value=" Test JS Right C++ Call of parameterless function (Window Binding)" onclick="javascript:testCallFunc()" />
<br/><hr /><br />
<input type="button" value=" Test JS Call multiple parameters C++ Function (Window Binding)" onclick="javascript: testCallFunc2()" /><input id="func2_input1" type="text" value=" Enter the parameters here 1" onclick=" if (this.value == ' Enter the parameters here 1') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}" /><input id="func2_input2" type="text" value=" Enter the parameters here 2" onclick=" if (this.value == ' Enter the parameters here 2') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}"/>
<br /><hr /><br />
<input type="button" value=" Test, call C++ Function modification 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 == ' Enter the value of the global variable here ') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}" />
<br /><hr/><br />
<input type="button" value=" Test fetch C++ In JS Window Properties set in the object (Window Binding)" onclick="javascript:testGetGlobalVar()" />
<br /><hr /><br />
<input type="button" value=" Test JS Call multiple parameters C++ Function ( Expansion mode )" onclick="javascript: alert(' Test JS Call multiple parameters C++ Function ( Expansion mode )=>' + 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 Call C++ Parametric function
function testCallFunc()
{
alert(window.myKagulaFunc());
}
// Test JS Call 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 correctly "head and tail" String.
}
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\n Old value: " + oldValue);
}
// Test JS Read C++ Variables set
function testGetGlobalVar()
{
alert(window.myKagulaVal);
}
// Test c++ Call JS
function myFunction() {
//document.getElementById("demo").style.color = "red";
alert("C++ Call JS Successful test !");
}
</script>