-2

Is there any way to do something like this in HTML, (or do you know of a quick javascript I can link to for this?)

<body>
<h1> Static Text </h1>
<p> <include href="snippets/dynamic.txt" /> </p>
</body>

Which would render the text inside of "dynamic.txt" as part of the webpage (client side) since this is a static site with no server side scripting engine.

JayPrime2012
  • 2,672
  • 4
  • 28
  • 44

1 Answers1

0

you can following this function in here Javascript - read local text file , i hope it can help

this is code in that

function readTextFile(file)
{
    var rawFile = new XMLHttpRequest();
    rawFile.open("GET", file, false);
    rawFile.onreadystatechange = function ()
    {
        if(rawFile.readyState === 4)
        {
            if(rawFile.status === 200 || rawFile.status == 0)
            {
                var allText = rawFile.responseText;
                alert(allText);
            }
        }
    }
    rawFile.send(null);
}

And specify file:// in your filename:

readTextFile("file:///C:/your/path/to/file.txt");
Community
  • 1
  • 1
scorpion
  • 147
  • 9