I have a text area in a 404 page on my website that is a monologue from the webserver to the user. This text uses a | character to represent the ‘cursor’ position in the monologue. Unfortunately, this character does not blink. After googling around and finding http://en.wikipedia.org/wiki/Blink_element#Implementation, I tried adding it to the page, but when I put the tags around the |, it shows as a literal instead of being interpreted.
The function for displaying the text is
function type_text()
{
contents='';
row=Math.max(0,index-7);
while(row < index)
{
contents += tl[row++] + '\r\n';
}
document.forms[0].elements[0].value = contents + tl[index].substring(0,text_pos) + "<blink>|</blink>";
if(text_pos++==str_length)
{
text_pos=0;
index++;
if(index!=tl.length)
{
str_length=tl[index].length;
setTimeout("type_text()",1500);
}
} else
setTimeout("type_text()",speed);
}
This is of course in Javascript.
I used this to script the <blink> tags:
function blink()
{
var blinks = document.getElementsByTagName('blink');
for (var i = blinks.length - 1; i >= 0; i--)
{
var s = blinks[i];
s.style.visibility = (s.style.visibility === 'visible') ? 'hidden' : 'visible';
}
window.setTimeout(blink, 500);
}
if (document.addEventListener) document.addEventListener("DOMContentLoaded", blink, false);
else if (window.addEventListener) window.addEventListener("load", blink, false);
else if (window.attachEvent) window.attachEvent("onload", blink);
else window.onload = blink;
If it helps at all, my page can be found here: http://paradoxwow.com/404.shtml I have a ‘Test’ message blinking in the bottom left, but the | won’t blink.
Thanks ahead.
A textarea cannot contain HTML, so you’re out of luck there. Since you aren’t really using the textarea for input, why use a textarea at all? Use a div instead, and modify your code appropriately.