79330151

Date: 2025-01-05 04:07:47
Score: 0.5
Natty:
Report link

To get the text from bar.txt you need to make a GET call using either XMLHttpRequest or fetch, whichever you prefer. Then you will need to set that text as the innerHTML property of the element you're interested in.

Note you will not be able to perform a GET call on your local machine without first spinning up a webserver.

Example:

foo.html:

<!DOCTYPE html>
<html>
    <head>
        <title>Read from .txt</title>
    </head>
    <body>
        <p>Below is the content of the text file:</p>
        <p id="foo"></p>
        <script>
fetch("bar.txt").then((response)=>{
    return response.text();
}).then((text)=>{
    document.getElementById('foo').innerHTML = text;
});
        </script>
    </body>
</html>

bar.txt:

What I want for Christmas:
<ul>
<li>Candy</li>
<li>Toys</li>
<li>My two front teeth</li>
</ul>

What the browser renders:

What the browser renders

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: computer programmer