@herodote92Feb 26.2005 — #I quickly developed the following one, it works: <i> </i><html> <head> <title></title> <script language=javascript> var x = ""; var s = "Hello, I am the typewriter."; var s1 = "";
@herodote92Feb 26.2005 — #Oh, dammit, when will all I write stop being misinterpreted. I didn't wink, I tried to write something like: ampersand, letter n, letter b, letter s, letter p, semicolon. Hope it comes through this time.
I improved the whole thing a little bit, and tested it in IE6, Netscape 7.2 and Mozilla 1.6. It works all right. Now the button will work every time you click on it, not only once. The text will be printed instead of the original question mark. <i> </i><html> <head> <title></title>
<script language=javascript>
var x = ""; var s = "Hello, I am the typewriter."; var s1 = "";
function Test() { s1 = "" document.getElementById("my_span").firstChild.data = s1; x = setInterval('AddChar()',200); } function AddChar() { if (s1.length >= s.length) { clearInterval(x); } else { s1 = s1 + s.substr(s1.length,1); document.getElementById("my_span").firstChild.data = s1; } } </script>
@herodote92Feb 26.2005 — #This version is even more funny: the script will type itself on the screen (I made the typing speed a little faster...): <i> </i><html> <head> <title></title>
</head>
<body> <style> .my_class {font-family:monospace; font-size:10pt; font-weight:bold; color:Black;} </style> <script language=javascript> var x = ""; var s = document.getElementsByTagName("script")[0].innerHTML; var s1 = ""; var i = 0;
function Test() { s1 = ""; i = 0; document.getElementById("my_pre").firstChild.data = s1; x = setInterval('AddChar()',50); } function AddChar() { if (i >= s.length) { clearInterval(x); } else { var my_car = s.substr(i,1); s1 += my_car; i += 1; document.getElementById("my_pre").firstChild.data = s1; } } </script> <input type="button" value="Show yourself ! (if you dare)" onclick="Test();"> <br><br> &lt;script language="javascript"&gt; <pre id="my_pre" class="my_class">?</pre> &lt;/script&gt; </body> </html>