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

248
Views
¿Puedo usar playaudio() antes de actualizar mi sitio?

hola, tengo un boton simple

<a onclick="window.location.href=window.location.href" class="btn"> Stop </a>

y tengo una fuente de audio

<audio id="myAudio"> <source src="https://myweb.com/files/tuntun.mp3" type="audio/mpeg"> </audio>

y esto es javascript

 <script> var x = document.getElementById("myAudio"); function playAudio() { x.play(); } </script>

quiero que se reproduzca el audio antes de actualizar la página cuando hago clic en el botón, lo intenté pero mi audio se detiene mientras se actualiza. Adiós, lo necesito para ANDIOID Browser

Espero que puedas entender lo que necesito porque soy malo en inglés.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tendrá que ejecutar una función al hacer clic... Eso reproducirá el audio y luego actualizará la página.

 <a onclick="playAudio()" class="btn"> Stop </a> <audio id="myAudio"> <source src="https://myweb.com/files/tuntun.mp3" type="audio/mpeg"> </audio>

 <script> let stopFlag = false let x = document.getElementById("myAudio"); function playAudio() { // Set a flag to know if the "stop" link was clicked stopFlag = true x.play(); } // An event listener to reload the page after the video has ended if the "Stop" link was cliked x.addEventListener('ended', () => { if(stopFlag){ window.location.reload() } }) </script>
about 4 years ago · Juan Pablo Isaza Report
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!