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

276
Views
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 answers
Answer question

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 Report

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 Report

0

try this

fetch('file.txt')
  .then(response => response.text())
  .then(text => { document.getElementById("videosource ").src =text;})
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!