How To Type On An Input Box Via Javascript For Ie
Trying to figure out how to type (via events not set the value) on an input box for IE8 and 9. I looked at some of the examples on the web - but couldnt get any of they to work. (I
Solution 1:
Try this function, fire(document.getElementById('txtfld'),'keypress',68)
:
functionfire(el,evttype,code) {
if (document.createEvent) {
var evt = document.createEvent('HTMLEvents');
evt.initEvent( evttype, false, false);
evt.charCode= evt.keyCode = code;
el.dispatchEvent(evt);
} elseif (document.createEventObject) {
var evt = document.createEventObject();
evt.charCode= evt.keyCode = code;
el.fireEvent('on' + evttype, evt);
}
}
good luck :)
Post a Comment for "How To Type On An Input Box Via Javascript For Ie"