HTML页面,测试JS对C函数的调取
发布时间:09/01 来源:未知 浏览:
关键词:
这里记一下,今后要用的时候可以查!
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio"> <meta http-equiv="content-type" content="text/html;charset=gbk"> <TITLE>HTML页面,测试JS对C函数的调取</TITLE> </HEAD> <BODY> <input type="button" value="测试JS对C++无参函数的调取(Window Binding)" onclick="javascript:testCallFunc()" /> <br/><hr /><br /> <input type="button" value="测试JS调取多参数C++函数(Window Binding)" onclick="javascript: testCallFunc2()" /><input id="func2_input1" type="text" value="这里输入参数1" onclick=" if (this.value == '这里输入参数1') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}" /><input id="func2_input2" type="text" value="这里输入参数2" onclick=" if (this.value == '这里输入参数2') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}"/> <br /><hr /><br /> <input type="button" value="测试,调取C++函数修改JS Window对象属性(Window Binding)" onclick="javascript: testCallFunc3()" /><input id="func3_input" type="text" value="这里输入全局变量的值" onclick=" if (this.value == '这里输入全局变量的值') { this.value = '' }" onblur="if(this.value==''){this.value='defaultValue'}" /> <br /><hr/><br /> <input type="button" value="测试取C++在JS Window对象中设定的属性(Window Binding)" onclick="javascript:testGetGlobalVar()" /> <br /><hr /><br /> <input type="button" value="测试JS调取多参数C++函数(扩展方式)" onclick="javascript: alert('测试JS调取多参数C++函数(扩展方式)=>' + 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/>'); //测试JS调取C++,无参函数 function testCallFunc() { alert(window.myKagulaFunc()); } //测试JS调取C++,带两个参数函数 function testCallFunc2() { var arg1 = document.getElementById("func2_input1").value; var arg2 = document.getElementById("func2_input2").value; alert(window.myKagulaFunc2(arg1,arg2)); //准确返回"head and tail"字符串。 } function testCallFunc3() { var oldValue = window.myKagulaVal; var arg = document.getElementById("func3_input").value; window.myKagulaFunc3(arg); var newValue = window.myKagulaVal; alert("新的值:" + newValue + "\r\n老的值:" + oldValue); } //测试JS读取C++设定的变量 function testGetGlobalVar() { alert(window.myKagulaVal); } //测试c++调取JS function myFunction() { //document.getElementById("demo").style.color = "red"; alert("C++调取JS测试成功!"); } </script>
以上就是HTML页面,测试JS对C函数的调取的具体内容,更多请关注百分百源码网其它相关文章!