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

622
Views
La función Javascript no se ejecuta en mi aplicación Flask
<!DOCTYPE html> <html> <head> </head> <body> <div id="load" class="load"> <h3 >{{load}}</h3> <img src="{{ load }}" id="image" style="height:500px;width:500px;" /> </div> <script type="text/javascript"> document.getElementById("image").addEventListener("loadstart", refresh); function refresh() { window.location.reload(); } </script> </body> </html>

El servidor Flask se ejecuta en http://0.0.0.0:5000/ , después de que cada nueva imagen HTTP POST se cargue en src="{{ load }}". Me gustaría que el sitio web se actualice solo con la función de actualización, pero no funciona. ¿Alguien tiene idea de por qué?

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

0

La imagen ya está cargada cuando se ejecuta su script

Además, las imágenes no tienen un inicio de carga

Utilice la carga de la ventana en su lugar

y dar al usuario la oportunidad de disfrutar de la imagen

 window.addEventListener("load", function() { setTimeout(function() { window.location.reload(1); },3000) })
 <div id="load" class="load"> <h3>{{load}}</h3> <img src="{{ load }}" id="image" style="height:500px;width:500px;" /> </div>

También puedes simplemente cargar la imagen.

 window.addEventListener("load", function() { setTimeout(function() { document.getElementById('image').src = '{{ load }}'; // you may want to add something random to not cache },3000) })
 <div id="load" class="load"> <h3>{{load}}</h3> <img src="{{ load }}" id="image" style="height:500px;width:500px;" /> </div>
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!