We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[https://www.w3.org/TR/uievents/#event-types-list] 总结就是:
使用UIEvent()构造函数
UIEvent()
var event = new UIEvent('scroll');
通过document.createEvent(type)创建,通过event.initUIEvent(type, canBubble, cancelable)初始化
document.createEvent(type)
event.initUIEvent(type, canBubble, cancelable)
var event = document.createEvent(‘UIEvent’); event.initUIEvent(‘scroll’, false, true);
var event; try { event = new UIEvent('scroll'); } catch (e) { event = document.createEvent('UIEvents'); event.initUIEvent('scroll', false, true); }
原因是虽然有些过时浏览器有window.UIEvent这个对象,但是做构造函数用时会抛出异常
window.UIEvent
element.dispatchEvent(event);
兼容大多数浏览器IE9+,Android2.3+,iOS4.1+
The text was updated successfully, but these errors were encountered:
No branches or pull requests
scroll事件的特点
[https://www.w3.org/TR/uievents/#event-types-list] 总结就是:
创建事件对象
现代浏览器里的推荐做法
使用
UIEvent()
构造函数兼容过时浏览器
通过
document.createEvent(type)
创建,通过event.initUIEvent(type, canBubble, cancelable)
初始化如果想在现代浏览器里使用新的构造函数,同时兼容过时浏览器,以下是推荐做法
原因是虽然有些过时浏览器有
window.UIEvent
这个对象,但是做构造函数用时会抛出异常最后触发事件
兼容大多数浏览器IE9+,Android2.3+,iOS4.1+
The text was updated successfully, but these errors were encountered: