<html><head>
<script type="text/javascript" language="JavaScript"><!--
var effect = false; // global variable, right?...so that I can have a stop function??
function doEffect(id)
{
effect = true;
var e = document.getElementById(id);
var c = new Array('|','/','-','\\');
var cnum = 0;
while(effect)
{
setTimeout("e.innerHTML = c[cnum];",1000); // line 12
cnum++;
if(cnum >= 4) cnum = 0;
}
}
function stopEffect(id)
{
effect = false;
var e = document.getElementById(id);
e.innerHTML = '';
}
//-->
</script></head>
<body>
<div id="stuff"></div>
<script type="text/javascript" language="JavaScript"><!--
doEffect('stuff');
//-->
</script>
</body>
</html>
Hmm... Well, everything about this script just seems to be wrong to me.
The loop inside of the function seems like a bad idea for being able to end it, and the loop is bound to crash a lot of browsers. I'd take everything step by step... It seems like you're trying to do too much at once rather than taking it little by little.
As for setTimeout, I haven't used it before. The fact that it takes a string bothers me.