为什么在这个简单的addEventListener函数之后使用'false'? [英] Why is 'false' used after this simple addEventListener function?

查看:339
本文介绍了为什么在这个简单的addEventListener函数之后使用'false'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最后的错误是什么?谢谢。

What is the false for at the end? Thanks.

window.addEventListener('load', function() {
  alert("All done");
}, false);


推荐答案

根据 MDN Web Docs ,第三个参数是:


useCapture

如果 true useCapture 表示用户希望
发起捕获。在启动
捕获后,指定
类型的所有事件将被分派到
注册的侦听器,然后将
调度到任何 EventTarget 在DOM树中的
下面。
向上冒泡到树上的事件将
不会触发指定为
的侦听器使用捕获。请参阅 DOM Level 3活动
详细解释。

useCapture
If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTargets beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture. See DOM Level 3 Events for a detailed explanation.

这篇关于为什么在这个简单的addEventListener函数之后使用'false'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆