怎样模拟键盘的事件?
var evObj = document.createEvent( 'MouseEvents ')
上面那样是模拟鼠标点击事件, 不知键盘输入事件又怎样做呢
如我想实现在一个input里输入 abc的字符串
------解决方案-------------------- <input id= "demo "/>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function key(s) {
var o = document.getElementById( "demo ");
o.focus();
for (var i = 0; i < s.length; i++) {
var e = document.createEvent( "KeyboardEvent ");
e.initKeyEvent( "keypress ", false, true, null,
false, false, false, false,
0, s.charCodeAt(i));
o.dispatchEvent(e);
}
}
key( "fason ");
//-->
</SCRIPT>
------解决方案--------------------用Wscript.Shell可以,不过有些地方会把这个当病毒