When uninstalling and reinstalling my copy of portable firefox (great browser btw), I came across an old web page I had done to create a couple of stupid scripts, the inspiration being this post by Leah Culver, and Leah if you read this and you won’t, pownce isn’t perfect but you’re edging it towards perfection.
Anyways I wrote three bad pieces of javascript, one to make it appear that the page is typing to you, one that makes it appear that the title of the page is being typed out and one that simply blinks the title as a means to annoy you. None of these serve any purpose but I didn’t want to forget my contribution to the world of stupid scripts so I figured I would post it here.
First of all i wanted to explain the global variables: string is simply the text to be echoed in some way, stringPortion is used to hold the portion of the text to be typed out (it’s not used in the the function echoTitle), count should probably be named something else but it is used to keep track of where you are at in the string when typing it out, and titleCount is used in the blinking title function as a means of remembering if the title is blank or not, I could have done that without a variable but when I wrote this I didn’t know as much as I know now as I was taking my first javascript course so I didn’t know the DOM at all, compared to the little I know now.
var string = “hello world”;
var stringPortion = “”;
var count = 0;
var titleCount = 0;
Now that you know the variables I will just post the functions, like I said they’re stupid scripts so they aren’t at all complex, heck none of them even take in any parameters they’re so quick and basic.
function echoString()
{
stringPortion = stringPortion + string.charAt(count);
document.getElementById(‘stringTest’).innerHTML = “<h1>”+stringPortion+”_</h1>”;
count++;
setTimeout(“echoString()”,250)
} // end function
function animateTitle()
{
stringPortion = stringPortion + string.charAt(count);
document.title = stringPortion+”_”;
count++;
setTimeout(“animateTitle()”,250)
} // end function echoString
function echoTitle()
{
if(titleCount == 0)
{
document.title = string;
titleCount++;
setTimeout(“echoTitle()”,800)
}
else
{
document.title = “”;
titleCount–;
setTimeout(“echoTitle()”,800)
}
} // end function