Why are some handlers not working on the page?
-
Added several handlers on the page
window.addEventListener ("load", function () {})
One of them definitely does not work, perhaps more than one. Is there a limit on the number of listeners?JavaScript Anonymous, Jul 23, 2020 -
There is no limit to the number of listeners.
However, there is stopImmediatePropagation
In the following code, 9 and 10 will not be output to the console.window.addEventListener("load", function() {
console.log(1);
});
window.addEventListener("load", function() {
console.log(2);
});
window.addEventListener("load", function() {
console.log(3);
});
window.addEventListener("load", function() {
console.log(4);
});
window.addEventListener("load", function() {
console.log(5);
});
window.addEventListener("load", function() {
console.log(6);
});
window.addEventListener("load", function() {
console.log(7);
});
window.addEventListener("load", function(e) {
e.stopImmediatePropagation();
console.log(8);
});
window.addEventListener("load", function() {
console.log(9);
});
window.addEventListener("load", function() {
console.log(10)
});Hudson Massey
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!