 |
Results from the most recent live auction are here.
15 members in the live chat room. Join Chat!
| |
07-18-2005, 06:53 PM
|
· #1 | | Account Closed Name: Cody Selzer Location: /etc/passwd Join Date: May 2004
Posts: 2,194
NP$: 0.00 ( Donate)
| Javascript live clock Save this as: clock.js Code:
//Coded by axilant[at]gmail.com
function clock() {
var curtime = new Date;
var hours = curtime.getHours();
if(hours < 10)
{
var hourstring = "0" + hours+toString();
}
else
{
var hourstring = hours.toString();
}
var minutes = curtime.getMinutes();
if(minutes < 10)
{
var minutestring = "0" + minutes.toString();
}
else
{
var minutestring = minutes.toString();
}
var seconds = curtime.getSeconds();
if(seconds < 10)
{
var secondstring = "0" + seconds.toString();
}
else
{
var secondstring = seconds.toString();
}
var timestring = hourstring + ":" + minutestring + ":" + secondstring;
var timeplace = document.getElementById("time");
timeplace.childNodes[0].nodeValue = timestring;
setTimeout('clock()', 1000);
}
setTimeout('clock()', 1000);
Save this as: index.htm Code:
<html lang="en">
<head>
<script src="clock.js">
</head>
<body>
<h2>Time:<div id="time">00:00:00</div></h2>
</body>
</html>
This should work in all browsers. Been tested in ie 6, and firefox (newest version)
Any questions or comments please post here.
Last edited by axilant : 07-20-2005 at 07:53 PM.
|
| |
07-19-2005, 09:32 PM
|
· #2 | | while ($awake){ code(); } Name: Eric Location: Kentucky Join Date: Mar 2005
Posts: 4,240
NP$: 385.00 ( Donate)
| |
| |
07-19-2005, 09:38 PM
|
· #3 | | Account Closed Name: Cody Selzer Location: /etc/passwd Join Date: May 2004
Posts: 2,194
NP$: 0.00 ( Donate)
| Yes, my mistake
Change the id to time instead of clock in the body
Fixed it above. |
| |
07-19-2005, 09:48 PM
|
· #4 | | while ($awake){ code(); } Name: Eric Location: Kentucky Join Date: Mar 2005
Posts: 4,240
NP$: 385.00 ( Donate)
| Ok, I edited and uploaded...But still, comes up blank.  |
| |
07-20-2005, 07:54 PM
|
· #5 | | Account Closed Name: Cody Selzer Location: /etc/passwd Join Date: May 2004
Posts: 2,194
NP$: 0.00 ( Donate)
| Hmm... use the new body code in the above... http://phpprint.com it works perfectly fine O.o same code... :-/ |
| |
08-22-2005, 05:17 AM
|
· #6 | | NamePros Regular Join Date: Mar 2005
Posts: 847
NP$: 29.00 ( Donate)
| you could also try this it's without the formatting:
<script type="tex/tjavascript">
function start_time(){
var nDate = new DATE();
var elem = document.getElementById ? document.getElementById("box")  (document.all) ? document.all("box"):null);
if(elem){
elem.innerText = nDate;
}
setTimeout("start_time()",100);
}
</script onload>
<body onload="start_time()">
<div id = "box"></div>
</body> |
| |
09-05-2005, 12:26 AM
|
· #7 | | Senior Member Name: Bharat Balegere Location: Bangalore Join Date: Jul 2005
Posts: 1,222
NP$: 282.60 ( Donate)
| Nice tip. |
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |