SlowCoder
12-03-2012, 09:18 PM
I'm building a multi-object Javascript blinker.
Something's broken, but I can't tell what.
<div id="agent1">blah</div>
<div id="agent2">bleh</div>
<script language="javascript" type="text/javascript">
var BlinkToggle = new Array();
BlinkToggle[1] = false;BlinkToggle[2] = true;
function BlinkText(AgentNum,objID){
BlinkToggle[AgentNum] = !BlinkToggle[AgentNum];
//document.write(BlinkToggle[AgentNum]);
BlinkObject=document.getElementById(objID);
if(BlinkToggle[AgentNum] == false)
{BlinkObject.style.visibility = 'hidden'}
else
{BlinkObject.style.visibility = 'visible'};
window.setTimeout(BlinkText(AgentNum,objID),3000);
}
BlinkText(1,"agent1");
BlinkText(2,"agent2");
</script>
1. IE gives me an out of memory error on line 13.
2. If I uncomment the doc.write command, it shows that the function appears to be looping, but obviously not once every 3 seconds.
3. I've tried using setTimeout with single and double quotes, and without any at all, around the called function.
Anyone tell me what's not working here?
Something's broken, but I can't tell what.
<div id="agent1">blah</div>
<div id="agent2">bleh</div>
<script language="javascript" type="text/javascript">
var BlinkToggle = new Array();
BlinkToggle[1] = false;BlinkToggle[2] = true;
function BlinkText(AgentNum,objID){
BlinkToggle[AgentNum] = !BlinkToggle[AgentNum];
//document.write(BlinkToggle[AgentNum]);
BlinkObject=document.getElementById(objID);
if(BlinkToggle[AgentNum] == false)
{BlinkObject.style.visibility = 'hidden'}
else
{BlinkObject.style.visibility = 'visible'};
window.setTimeout(BlinkText(AgentNum,objID),3000);
}
BlinkText(1,"agent1");
BlinkText(2,"agent2");
</script>
1. IE gives me an out of memory error on line 13.
2. If I uncomment the doc.write command, it shows that the function appears to be looping, but obviously not once every 3 seconds.
3. I've tried using setTimeout with single and double quotes, and without any at all, around the called function.
Anyone tell me what's not working here?