Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Message event not following the order of event listeners execution with capture parameter in addEventListener

I was going through this article about Javascript Eventing where the author beautifully explained about three phases of eventing(capturing, target, bubbling) and how events originate and how they travel in the DOM. According to it, the event first travels in the capture phase, then target phase and in end, it goes through bubbling phase.Hence,if there are two listeners attached on the same element for the same event, one at capturing phase and another at bubbling phase, then the event listener attached at capturing phase will be called first followed by event listener attached at bubbling phase.

I tried the above process for click event and message event. The click event is following the above behaviour but message event is not. Please find the code snippets for both cases:

window.addEventListener("message", function(e) {console.log("FALSE MESSAGE");}, false); 
window.addEventListener("message", function(e) {console.log("TRUE MESSAGE");}, true);

window.addEventListener("click", function(e) {console.log("FALSE CLICK MESSAGE");}, false);
window.addEventListener("click", function(e) {console.log("TRUE CLICK MESSAGE");}, true);

Message Event Case

Click Event Case

Why message event is behaving differently and not like other normal events?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!