okay, i have an external javascript file (.js) that creates a binary clock...it looks like this:<!-- beginfunction bClock() { if (!document.layers && !document.all) { return; } timePortion = new Array; maxLength = new Array; var timeGet = new Date(); timePortion[0] = timeGet.getHours(); timePortion[1] = timeGet.getMinutes(); timePortion[2] = timeGet.getSeconds(); maxLength[0] = 5; maxLength[1] = 6; maxLength[2] = 6; var decimalValue = 0; var decimalMod = 0; var tempTime = ""; for (var currentPortion = 0; currentPortion <= 2; currentPortion++) { decimalValue = timePortion[currentPortion]; timePortion[currentPortion] = ""; while (decimalValue != 0) { decimalMod = decimalValue % 2; decimalValue = Math.floor(decimalValue / 2); timePortion[currentPortion] = decimalMod + timePortion[currentPortion]; } if (timePortion[currentPortion].length < maxLength[currentPortion]) { for (var i = 1; i <= maxLength[currentPortion] - timePortion[currentPortion].length; i++) { tempTime += "0"; } } timePortion[currentPortion] = tempTime + timePortion[currentPortion]; tempTime = ""; } timeDisplay = '['+timePortion[0]+'|'+timePortion[1]+'|'+timePortion[2]+'] '; if (document.layers) { document.layers.bclock.document.write(timeDisplay); document.layers.bclock.document.close(); } else if (document.all) { bclock.innerHTML = timeDisplay; } setTimeout("bClock()", 1000);}window.onload = bClock; // end -->i include the file using <script src="bclock.js" language="javascript" type="text/javascript"></script> in the headerwherever i put <span id="bclock"></span> on the page, the binary clock shows up fine...in IEi realize this is because document.layers and document.all are not standard, while document.getElementById is...i know very little about javascripting (obviously) and while i'm sure i'll get some sarcastic comments concerning the fact that this is a stupid question and i should learn javascript, i was hoping someone could point out to me how i should change the scripting so that it will conform to the standard and therefore show up in firefoxthanks in advance[Edited on September 13, 2006 at 12:11 PM. Reason : formatting]
9/13/2006 12:06:44 PM
haah u n00b, you should learn javascript
9/13/2006 12:16:35 PM
If it works in IE then dont worry about it.
9/13/2006 12:16:51 PM
^^ see, in all reality, i think learning javascript would be pointless for me as1.) i am not a web designer by trade, only by hobby2.) using javascript for ANYTHING other than accenting a site is bad formi did this code a LONG time ago, when i had the viewpoint of ^
9/13/2006 12:21:42 PM
i was just joking... maybe I should learn how to joke.I don't blame you.
9/13/2006 12:23:08 PM
i know you were but aside from laziness, i really HAVE decided it wouldn't be worth my time...though i did try to google it, which is where i found out about the getElementById thing
9/13/2006 12:25:51 PM
9/13/2006 12:26:02 PM
but i'm trying to further my knowledge in this small way
9/13/2006 12:41:11 PM
9/13/2006 12:49:48 PM
9/13/2006 1:29:03 PM
<html><head> <script type="text/JavaScript"> function bClock() { timePortion = new Array; maxLength = new Array; var timeGet = new Date(); timePortion[0] = timeGet.getHours(); timePortion[1] = timeGet.getMinutes(); timePortion[2] = timeGet.getSeconds(); maxLength[0] = 5; maxLength[1] = 6; maxLength[2] = 6; var decimalValue = 0; var decimalMod = 0; var tempTime = ""; for (var currentPortion = 0; currentPortion <= 2; currentPortion++) { decimalValue = timePortion[currentPortion]; timePortion[currentPortion] = ""; while (decimalValue != 0) { decimalMod = decimalValue % 2; decimalValue = Math.floor(decimalValue / 2); timePortion[currentPortion] = decimalMod + timePortion[currentPortion]; } if (timePortion[currentPortion].length < maxLength[currentPortion]) { for (var i = 1; i <= maxLength[currentPortion] - timePortion[currentPortion].length; i++) { tempTime += "0"; } } timePortion[currentPortion] = tempTime + timePortion[currentPortion]; tempTime = ""; } timeDisplay = '['+timePortion[0]+'|'+timePortion[1]+'|'+timePortion[2]+'] '; document.getElementById("clk").innerHTML = timeDisplay;} </script></head><body onload="window.tmr = setInterval(bClock, 999)" onunload="clearInterval(window.tmr)"><h1><center><span ID="clk"></span></h1></center></body></html>
9/13/2006 1:32:26 PM
^^^ it can indeed enhance it...but relying on javascript as an integral part of your site is dumb...there is a significant percentage of users who block javascripting^^ i FOUND OUT about it...i couldn't find a sample of how to replace the document.innerHTML with it, though...if you know what i'm looking for, i'd appreciate some guidance[Edited on September 13, 2006 at 1:47 PM. Reason : .]
9/13/2006 1:34:36 PM
I'm not sure what you're talking about, but what I posted (^^) works in Firefox.
9/13/2006 1:46:01 PM
sorry...when i replied, your post didn't show up, and i didn't scroll down replacingif (document.layers) { document.layers.bclock.document.write(timeDisplay); document.layers.bclock.document.close(); } else if (document.all) { bclock.innerHTML = timeDisplay; }withdocument.getElementById("bclock").innerHTML = timeDisplay;works perfectly...thanks A Tanzarian![Edited on September 13, 2006 at 1:55 PM. Reason : .]
9/13/2006 1:47:54 PM