为什么.fireEvent()在IE9中不起作用? [英] Why does .fireEvent() not work in IE9?
本文介绍了为什么.fireEvent()在IE9中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
与IE9相比令人沮丧的时间。此代码适用于IE7 / 8,但不适用于9。
Rather frustrating time here with IE9. This code works in IE7/8, but not 9.
document.getElementById('id').fireEvent("OnChange");
有关原因的任何见解?
推荐答案
在IE版本> = 9和所有其他浏览器中,您应该使用 dispatchEvent
方法:
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);
这篇关于为什么.fireEvent()在IE9中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文