function fn_KeyboardEvent() {
//var element = document.getElementById('txtMainSearch');
//element.dispatchEvent(new KeyboardEvent('keydown', {
// 'key': 'a'
//}));
var event;
var eventName = "keydown";
var element = document.getElementById('txtMainSearch');
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventName, true, true);
} else if (document.createEventObject) {// IE < 9
event = document.createEventObject();
event.eventType = eventName;
}
event.eventName = eventName;
if (element.dispatchEvent) {
element.dispatchEvent(event);
}
else if (element.fireEvent && htmlEvents['on' + eventName]) {// IE < 9
element.fireEvent('on' + event.eventType, event);
}
else if (element[eventName]) {
element[eventName]();
}
else if (element['on' + eventName]) {
element['on' + eventName]();
}
}
댓글 없음:
댓글 쓰기