Skip to content
New issue

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

关于 window.addEventListener & window.dispatchEvent 的使用 #12

Open
JslinSir opened this issue May 31, 2022 · 0 comments
Open

关于 window.addEventListener & window.dispatchEvent 的使用 #12

JslinSir opened this issue May 31, 2022 · 0 comments
Labels
javaScript 奇巧淫技 开发中遇到的一些奇巧淫技

Comments

@JslinSir
Copy link
Owner

window.addEventListener 的解释

EventTarget.addEventListener() 方法将指定的监听器注册到 EventTarget 上,当该对象触发指定的事件时,指定的回调函数就会被执行。 事件目标可以是一个文档上的元素 Element,DocumentWindow或者任何其他支持事件的对象 (比如 XMLHttpRequest)。

window.addEventListener('sendMsg',function(){
	console.log('who dispatch this event?')
}, false);

var res = window.dispatchEvent(new Event('sendMsg'))
@JslinSir JslinSir added the 奇巧淫技 开发中遇到的一些奇巧淫技 label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javaScript 奇巧淫技 开发中遇到的一些奇巧淫技
Projects
None yet
Development

No branches or pull requests

1 participant