标签:
1.手动点击网页按钮C++后台响应
2.设置自动触发事件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <style type="text/css"> #button1 { width: 306px; } #button2 { width: 306px; } </style> <script language="javascript" type="text/javascript"> function Test() { alert("你调用了Test"); } function GlobalObject() { this.Test=function() { alert("你调用了GlobalObject.Test"); } } function OnTest() { alert("自动触发事件"); } var globalObject = new GlobalObject(); // 两秒后模拟点击 setTimeout(function () { // IE if (document.all) { document.getElementById("clickMe").click();//找到对应元素进行点击 } // 其它浏览器 else { var e = document.createEvent("MouseEvents"); e.initEvent("click", true, true); document.getElementById("clickMe").dispatchEvent(e); } }, 2000); </script> </head> <body> 测试页面<br /> <br /> <a href="#" id="clickMe" onclick="OnTest();">link</a> <input id="button1" type="button" value="点击演示在C++中处理按钮的onclick事件" /> <br /> <br /> <input id="button2" type="button" value="点击调用客户端的CppCall函数" onclick="return window.external.CppCall()" /> <br /> <br /> <p id="p1">Hello World!</p> <br /> <div id="size_info"></div> </body> </html>
标签:
原文地址:http://www.cnblogs.com/chechen/p/5594937.html