dimanche 2 novembre 2014

Typewriter look from a text file


Vote count:

0




I'm a really new Javascript person who for the first time is trying to write (rather than copy) code for a page. Simply put, I wish to read a text file then display the characters one at a time in a div already created. The 'get' corks fine and the data variable receives the string, however, I get a 'Line 1' input past error from the browser when this executes. Probably 10 things wrong with how I am going about it, but any direction welcome.



enter code here

<div id='textelement' style="width:400px; height:200px ;overflow:auto"></div>
<script type="text/javascript">
$.get("Comments.txt", function (data)
{
var displaytxt = "";
displaytxt = data;
function nextchar ()
{
if (displaytxt.length > 0)
{
$('#textelement').append(displaytxt.substr(0, 1));
displaytxt = displaytxt.substr(1);
setTimeout(nextchar, 70);
}
}
}
</script>


asked 28 secs ago







Typewriter look from a text file

Aucun commentaire:

Enregistrer un commentaire