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

177
Views
Using a button but receiving: DOMException: play() failed because the user didn't interact with the document first

I am currently getting this error on Google Chrome when trying to run a JS function that plays sound on a button click.

here is the code:

index.html

<button type="button" id="test-button">Test C Key</button>
index.js

function playNote() {
  let audio = new Audio('sounds/c-major.wav')
  audio.play()
  }

document.getElementById('test-button').addEventListener('click', playNote())

Error:

index.js:3 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. 

Any advice on how to overcome this? I understand that it can't play automatically but I am using a button click for trigger.

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!