Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
How to open a new video every time the page is reloaded in HTML

I'm a beginner in Web development, but now have started to write cool websites. I applied a video background to my webpage, did all the stylings, and looks cool, but how can I change it every time I reload the HTML page?

<video id="vidtest" autoplay muted loop>
      <source src= "videos/vid.mp4" type="video/mp4">
    </video>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Create an array with your video paths in it, randomly select an array item, then set it as the src attribute of your video source:

var source = document.getElementById('video-source');

var videos = [
  "vid1.mp4",
  "vid2.mp4",
  "vid3.mp4"
];

var randomVideo = videos[Math.floor(Math.random() * videos.length)];

source.setAttribute('src', randomVideo);
<video id="vidtest" autoplay muted loop>
  <source id="video-source" src= "videos/vid.mp4" type="video/mp4">
</video>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda