<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>
function
testCallFunc()
{
alert(window.myKagulaFunc());
}
function
testCallFunc2() {
var
arg1 = document.getElementById(
"func2_input1"
).value;
var
arg2 = document.getElementById(
"func2_input2"
).value;
alert(window.myKagulaFunc2(arg1,arg2));
}
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);
}
function
testGetGlobalVar()
{
alert(window.myKagulaVal);
}
function
myFunction() {
alert(
"C++调用JS测试成功!"
);
}
</script>