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

135
Vistas
Can put a link in a video element

So I'm trying to put a link inside a Video element and It wont work here is the code, also How do You make a Variable as string in JS ??

    var link = prompt("Enter The Website You Wanna Stream:");
    document.getElementById("PLAYER").innerHTML = "<source src='" + link + "' type='video'>";
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

A simple way of changing the source of a video based on your code in js:

const link = prompt('Enter video Link');
const video = document.querySelector('video');
video.src = link;

full code for a test:

setTimeout(() =>{

// setting a timeout of 3s

const link = prompt('Enter video Link');
const video = document.querySelector('video');
video.src = link;

} , 3000)
<video src="https://hw5.cdn.asset.aparat.com/aparat-video/09b40b525d19c2459557117619da2c7f12978678-240p.mp4?wmsAuthSign=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6IjlkNTQwYTJiMmNkZDAzMDFjODNlNjIxNjlmOWVjY2ZkIiwiZXhwIjoxNjM5MDkyNTY4LCJpc3MiOiJTYWJhIElkZWEgR1NJRyJ9.PTLqt9ltqbosdJr27icnfc_4PhUG4oVX2_IPxVXdqro" autoplay muted controls></video>

and to make a variable string you can use .toString()

const num = 123;
const str = num.toString();     

bear in mind in too many cases .toString() is not needed in js. I suggest you see: js data types as well as js operators

about 4 years ago · Juan Pablo Isaza Denunciar

0

Your code is ok. You need only wrapped in the video Tag.

function myFunction() {
  const link = prompt("Enter The Website You Wanna Stream:");
  if (link != null) {
    document.getElementById("PLAYER").innerHTML = `<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">  
Your browser does not support the video tag.
</video>`;
  }
}
<button onclick="myFunction()">Try it</button>

<div id="PLAYER"></div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

So I found the answer a few Minutes After I posted this which is I Have To Put The Java Script Code after The element or I have to wait For The Whole Page To Load And Then Execute The Code. If You Think You Have other Ways To Solve This Please Post a Answer

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