Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
How to read url from .txt file and use in html src?

How can I read url from a txt file and use in html? I have a video source url in .txt file. How can I use this url in the html file? Sometimes I want to edit the video source in the .txt file.

In the /videosrc.txt:

http://www.videoexaple.com/videos/video.mp4

In /index.html file:

<html>
<head>
<title></title>
</head>
<body>

<video id="video">

<source id="videosource" src=" -url from /video.txt- " type='video/mp4'>

</video>

</body>
</html>
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

I would recommend that you give this a read: https://www.w3schools.com/php/php_file_open.asp See the first example and you can see the output of the file.

This shows you how to access information within a file. Then it is just a matter of putting the data at the correct place.

about 4 years ago · Juan Pablo Isaza Relatório

0

The simplest is to have a file with the extension .js - for example video.js in the same folder as the html file

It looks like this:

const videoURL = "https://www.videoexaple.com/videos/video.mp4";

then in your HTML have

<script src="video.js"></script>
<script>
  window.addEventListener("DOMContentLoaded",function() {
    document.getElementById("videosource").src = videoURL;
  })
</script>
about 4 years ago · Juan Pablo Isaza Relatório

0

try this

fetch('file.txt')
  .then(response => response.text())
  .then(text => { document.getElementById("videosource ").src =text;})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda