Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

EventTarget.fireEvent()

这篇翻译不完整。请帮忙从英语翻译这篇文章

非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

概述

这是微软IE浏览器用以替代EventTarget.dispatchEvent()的私有方法,与EventTarget.dispatchEvent()不同的是通过fireEvent() 触发的事件不会触发事件的默认行为,例如,通过fireEvent()触发<input type="checkbox">的点击事件并不会切换checkbox的选中状态

语法

cancelled = target.fireEvent(eventNameWithOn, event)
target
要触发事件的元素
eventNameWithOn
要触发事件的名字,前缀为“on”,例如,可以用过"onclick"来触发点击事件
event
要触发的事件对象
cancelled
布尔值,事件是否被事件句柄取消

规范

无此部分的规范

微软的描述: has a description on MSDN.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 未实现 未实现 6 到 10 [1] ? 未实现
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 未实现 未实现 ? ? 未实现

[1]: fireEvent()在IE11+已经不再支持,EventTarget.dispatchEvent()在IE9+已经支持

相关链接

文档标签和贡献者

 此页面的贡献者: pod4g
 最后编辑者: pod4g,