I’m doing something wrong but WHAT! I’ve looked over it a hundred times. For some reason, it isn’t retrieving the object from the document. Here is my index and Javascript source:
var blinkOn =false;
var blinkObj=document.getElementById("blink");
function blinkCursor() {
if (blinkOn)
{
blinkObj.style.display="none";
} else {
blinkObj.style.display="inline";
}
blinkOn=!blinkOn;
setTimeout("blinkCursor()",500);
}
blinkCursor();
INDEX:
<html>
<head>
<title>
CMD.exe
</title>
<link rel="stylesheet" type="text/css" href="cmd.css" />
<script language="JavaScript" SRC="cmd.js"></script>
</head>
<body>
<span id="content">></span><span style="display:none;" id="blink" >|</span>
</body>
</html>
Any help would be so much help! (well.. wait… duh :p )
Your problem is that your JavaScript is executing before the HTML is interpreted – the DOM has not loaded.
While I’d recommend that you use something like jQuery to ensure document readiness, here’s your problem solved without it: