Why does .fireEvent() not work in IE9?

Rather frustrating time here with IE9. This code works in IE7/8, but not 9.

document.getElementById('id').fireEvent("OnChange");

Any insight as to why?

Answers:

Answer

In IE versions >= 9 and all other browsers you should use the dispatchEvent method:

var event = document.createEvent("HTMLEvents");
event.initEvent("change",true,false);

document.getElementById("id").dispatchEvent(event);

Check out http://jsfiddle.net/QKsvv/

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.