JavaScript - Clock Script Stops Updating When Scrolling Down
My bad if this was answered somewhere else. I did search the forums but was unable to locate an answer (It is kind of a specific question)
I have an odd problem. I have the following clock script: Code: function Clock() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add lead zeros to numbers less than 10 h=checkTime(h); m=checkTime(m); s=checkTime(s); document.getElementById('Clock').innerHTML=h+":"+m+":"+s; t=setTimeout('Clock'), 500); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } Loaded at the page load and assigned to a div: Code: <body onLoad = "Clock();"> <!--the clock--> <div align = "right" id = "Clock"></div> With this style applied: Code: #Clock {font-size: 30pt; position: fixed; top: 0px; right: 0px; background: #ffffff; z-index: 3; } The problem I've run into is this: In Chrome, whenever I scroll down, even by just one tap/click of the down arrow, the clock stops updating the time in, pardon the pun, real-time. But the second I scroll completely to the top of the page, it goes back to counting. I tested in the current (as of Nov 20th 2010) versions of FireFox, Opera and IE9 and the only browser that seems to produce this problem is Chrome. Any ideas? Similar TutorialsI have a clock that works onbodyload, however using the below function on the same page, stops my clock even coming up, any help would be great. Code: <script language="JavaScript"> var HAS_EXPIRED = 'Time has Expired!'; var IS_NONE = 'None'; function secondCountdown(s){ if(s){ var timeleft = document.getElementById('timeleft').innerHTML; if((timeleft == HAS_EXPIRED) || (timeleft == IS_NONE)) return false; timeleft = timeleft.replace('<font>', ''); timeleft = timeleft.replace('</font>', ''); var time = timeleft.split(":"); var secs = time[2] * 1; var mins = time[1] * 1; var hrs = time[0] * 1; secs += (mins * 60) + (hrs * 3600); secs -= 1; if(secs <= 0){ document.getElementById('timeleft').innerHTML = HAS_EXPIRED; return false; } else { hrs = Math.floor(secs/3600); secs -= (hrs * 3600); mins = Math.floor(secs/60); secs -= (mins * 60); if(hrs < 10) hrs = '0' + hrs; if(mins < 10) mins = '0' + mins; if(secs < 10) secs = '0' + secs; document.getElementById('timeleft').innerHTML = hrs + ':' + mins + ':' + secs; } } setTimeout('secondCountdown(true)',1000); } bootloaderAdd('secondCountdown()'); bootloaderOn(); </script> Hello, I want to change time format from 12 to 24 hours and remove AM and PM in this script. Anybody can help me? Code: <style type="text/css"> /*<![CDATA[*/ #clock { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size:16px; color:#030; padding-top: 24px; text-align:center; } /*//]]>*/ </style> <script type='text/javascript'> //<![CDATA[ var dayarray=new Array('Svē','Pir','Otr','Tre','Cet','Pie','Ses'); var montharray=new Array('01','02','03','04','05','06','07','08','09','10','11','12'); function getthedate(){ mydate=new Date(); year=mydate.getUTCFullYear(); day=mydate.getDay(); month=mydate.getMonth(); daym=mydate.getDate(); if(daym<10) { daym='0'+daym; } hours=mydate.getHours(); minutes=mydate.getMinutes(); seconds=mydate.getSeconds(); dn='AM'; if(hours>=12) { dn='PM'; } dn='AM'; if(hours>=12) { dn='PM'; } if(hours>12){ hours=hours-12; } if(hours==0){ hours=12; } if(minutes<=9) { minutes='0'+minutes; } if(seconds<=9) { seconds='0'+seconds; } cdate=dayarray[day]+', '+daym+'-'+montharray[month]+'-'+year+', '+hours+':'+minutes+':'+seconds+' '+dn; document.getElementById('clock').firstChild.nodeValue=cdate; setTimeout('getthedate()',1000); } window.onload=function() { getthedate(); } //]]> </script> Thanks. I'm building a website with scrolling images at the top, I managed to find some code which seemed to work fine but then when I uploaded it to the server there were suddenly huge gaps between the images. www.s-remy.com/B/index.html here's the code for the scrolling Code: <script type="text/javascript"> <!-- // ********** User Defining Area ********** data=[ ["scroll1.png","",""], ["scroll3.png","",""] // no comma at end of last index ] imgPlaces=40 // number of images visible imgWidth=50 // width of the images imgHeight=81 // height of the images imgSpacer=4 // space between the images dir=0 // 0 = left, 1 = right newWindow=0 // 0 = Open a new window for links 0 = no 1 = yes // ********** End User Defining Area ********** moz=document.getElementById&&!document.all step=1 timer="" speed=50 nextPic=0 initPos=new Array() nowDivPos=new Array() function initHIS3(){ for(var i=0;i<imgPlaces+1;i++){ // create image holders newImg=document.createElement("IMG") newImg.setAttribute("id","pic_"+i) newImg.setAttribute("src","") newImg.style.position="absolute" newImg.style.width=imgWidth+"px" newImg.style.height=imgHeight+"px" newImg.style.border=0 newImg.alt="" newImg.i=i newImg.onclick=function(){his3Win(data[this.i][2])} document.getElementById("display_area").appendChild(newImg) } containerEL=document.getElementById("his3container") displayArea=document.getElementById("display_area") pic0=document.getElementById("pic_0") containerBorder=(document.compatMode=="CSS1Compat"?0:parseInt(containerEL.style.borderWidth)*2) containerWidth=(imgPlaces*imgWidth)+((imgPlaces-1)*imgSpacer) containerEL.style.width=containerWidth+(!moz?containerBorder:"")+"px" containerEL.style.height=imgHeight+(!moz?containerBorder:"")+"px" displayArea.style.width=containerWidth+"px" displayArea.style.clip="rect(0,"+(containerWidth+"px")+","+(imgHeight+"px")+",0)" imgPos= -pic0.width for(var i=0;i<imgPlaces+1;i++){ currentImage=document.getElementById("pic_"+i) if(dir==0){imgPos+=pic0.width+imgSpacer} // if left initPos[i]=imgPos if(dir==0){currentImage.style.left=initPos[i]+"px"} // if left if(dir==1){ // if right document.getElementById("pic_"+[(imgPlaces-i)]).style.left=initPos[i]+"px" imgPos+=pic0.width+imgSpacer } if(nextPic==data.length){nextPic=0} currentImage.src=data[nextPic][0] currentImage.alt=data[nextPic][1] currentImage.i=nextPic currentImage.onclick=function(){his3Win(data[this.i][2])} nextPic++ } scrollHIS3() } timer="" function scrollHIS3(){ clearTimeout(timer) for(var i=0;i<imgPlaces+1;i++){ currentImage=document.getElementById("pic_"+i) nowDivPos[i]=parseInt(currentImage.style.left) if(dir==0){nowDivPos[i]-=step} if(dir==1){nowDivPos[i]+=step} if(dir==0&&nowDivPos[i]<= -(pic0.width+imgSpacer) || dir==1&&nowDivPos[i]>containerWidth){ if(dir==0){currentImage.style.left=containerWidth+imgSpacer+"px"} if(dir==1){currentImage.style.left= -pic0.width-(imgSpacer*2)+"px"} if(nextPic>data.length-1){nextPic=0} currentImage.src=data[nextPic][0] currentImage.alt=data[nextPic][1] currentImage.i=nextPic currentImage.onclick=function(){his3Win(data[this.i][2])} nextPic++ } else{ currentImage.style.left=nowDivPos[i]+"px" } } timer=setTimeout("scrollHIS3()",speed) } function stopHIS3(){ clearTimeout(timer) } function his3Win(loc){ if(loc==""){return} if(newWindow==0){ location=loc } else{ //window.open(loc) newin=window.open(loc,'win1','left=430,top=340,width=300,height=300') // use for specific size and positioned window newin.focus() } } // add onload="initHIS3()" to the opening BODY tag // --> I'm not very familiar with JavaScript so I can't find any issues with it. I've tried changing the imgspace value but it doesn't seem to work? Hi, I am looking for a script for a scrolling DIV with the following features: 1. DIV can be scrolled vertically using mousewheel/trackpad/finger on iPad 2. Up/Down buttons which scroll slowly on hover and fast on click 3. The DIV to be scrolled will contain an audio playlist, generated by jPlayer, written in javascript. This script has a DIV for the currently playing track, and can launch functions on track change. I would like the scrolling DIV to scroll automatically to the currently playing song when the track changes. Any help to get me going on this would be appreciated, Thanks Nick when someone selects a date it shows ok in the field but the checker script can not view it for some reason, i have an alert show the content, if i place the alert before everything it unblurs and the tick shows, but i have to click the alert off for the tick to show. The alert show nothing on the first run. just a thought, but would the DOM not be updating quick enough for the next line to read the content ? reason i ask is that with the alert line in the code it shows the previous state of the field when i change the date to something else. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type='text/javascript'> function checkValidFormInput() { redX = '<img alt="Invalid" src="images/redX.png" style="width: 18px;">'; greenTick = '<img alt="Valid" src="images/icongreentick.png">'; alert('.' + document.getElementsByName('j1date')[0].value + '.'); document.getElementsByName('j1date').blur(); if (document.getElementsByName('j1date')[0].value == '') { document.getElementById('j1dateImg').innerHTML = redX;// } else { document.getElementById('j1dateImg').innerHTML = greenTick;// } } </script> </head> <body> <? // for some strange reason the following lines need to be here for the date picker to work! ?> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <tr><td id="ds_calclass"></td></tr> </table> <script type="text/javascript" src="datetimepicker.js"></script> <? // end of date picker storage ?> <form method="POST" action="index.php"> <li class="value"> <input type="text" autocomplete="off" name="j1date" id="j1date" value="<?=$j1date;?>" style="width: 200px; float: left;" onClick="ds_sh(this);" onBlur="checkValidFormInput();"> <div style="float: left;" id="j1dateImg"></div><br style="clear:both"> </li> </form> </body> </html> attached is the datetimepicker.js you will need to remove the last part .txt from the above file name Hi everyone, I'm curious if this is something simple. I'm working on a wordpress site using a plugin that is based off of the code from javascript kit called "highlighter scroller script". The plugin js is almost identical: http://javascriptkit.com/script/cut57.shtml What is causing it to wipe from left to right? I'm racking my brains trying to figure it out (and googling unsuccessfully it seems). All I'm trying to do is make it wipe instead from right to left. I'm sure it's something simple, but I don't know which variable to change. Can anyone point me in the right direction? THANKS! Hello. I am trying to stop and then start my clock, but something goes wrong Code: <script type="text/javascript"> function start_clock(){ var today = new Date(); var h = today.getHours(); var m = today.getMinutes(); var s = today.getSeconds(); // add a zero in front of numbers<10 m = checkTime(m); s = checkTime(s); document.getElementById('clck').innerHTML = h+":"+m+":"+s; t=setTimeout('start_clock()'); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } var intval="" function start_Int(){ if(intval==""){ intval=window.setInterval("start_clock()",1000) }else{ stop_Int() } } function stop_Int(){ if(intval!=""){ window.clearInterval(intval) intval="" myTimer.innerHTML="Interval Stopped" } } </script> <h1>A live clock in JavaScript</h1> </head> <body onload="start_clock()"> <p>The time according to your PC is </p> <span id="clck">Interval Stopped</span> <br><br><br> <input type="button" value="Start" onclick="start_Int()"> <input type="button" value="Stop" onclick="stop_Int()"> Any help will be appreciated. Is there a way to bounce my image scroller back to the left using object.watch() or something?! at the moment, it reaches the end and stops here is my code from www.dyn-web.com Code: /************************************************************************* This code is from Dynamic Web Coding at www.dyn-web.com Copyright 2001-4 by Sharon Paine See Terms of Use at www.dyn-web.com/bus/terms.html regarding conditions under which you may use this code. This notice must be retained in the code as is! *************************************************************************/ /* dw_hoverscroll.js version date: June 2004 mouseover scrolling for dw_scrollObj (in dw_scrollObj.js) */ dw_scrollObj.stopScroll = function(wnId) { if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].endScroll(); } // increase speed onmousedown of scroll links dw_scrollObj.doubleSpeed = function(wnId) { if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed *= 2; } dw_scrollObj.resetSpeed = function(wnId) { if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed /= 2; } // algorithms for time-based scrolling and scrolling onmouseover at any angle adapted from youngpup.net dw_scrollObj.initScroll = function(wnId, deg, sp) { if ( dw_scrollObjs[wnId] ) { var cosine, sine; if (typeof deg == "string") { switch (deg) { case "up" : deg = 90; break; case "down" : deg = 270; break; case "left" : deg = 180; break; case "right" : deg = 0; break; default: alert("Direction of scroll in mouseover scroll links should be 'up', 'down', 'left', 'right' or number: 0 to 360."); } } deg = deg % 360; if (deg % 90 == 0) { cosine = (deg == 0)? -1: (deg == 180)? 1: 0; sine = (deg == 90)? 1: (deg == 270)? -1: 0; } else { var angle = deg * Math.PI/180; cosine = -Math.cos(angle); sine = Math.sin(angle); } dw_scrollObjs[wnId].fx = cosine / ( Math.abs(cosine) + Math.abs(sine) ); dw_scrollObjs[wnId].fy = sine / ( Math.abs(cosine) + Math.abs(sine) ); dw_scrollObjs[wnId].endX = (deg == 90 || deg == 270)? dw_scrollObjs[wnId].x: (deg < 90 || deg > 270)? -dw_scrollObjs[wnId].maxX: 0; dw_scrollObjs[wnId].endY = (deg == 0 || deg == 180)? dw_scrollObjs[wnId].y: (deg < 180)? 0: -dw_scrollObjs[wnId].maxY; dw_scrollObjs[wnId].startScroll(sp); } } // speed (optional) to override default speed (set in dw_scrollObj.speed) dw_scrollObj.prototype.startScroll = function(speed) { if (!this.ready) return; if (this.timerId) clearInterval(this.timerId); this.speed = speed || dw_scrollObj.speed; this.lyr = document.getElementById(this.lyrId); this.lastTime = ( new Date() ).getTime(); this.on_scroll_start(); this.timerId = setInterval(this.animString + ".scroll()", 10); } dw_scrollObj.prototype.scroll = function() { var now = ( new Date() ).getTime(); var d = (now - this.lastTime)/1000 * this.speed; if (d > 0) { var x = this.x + this.fx * d; var y = this.y + this.fy * d; if (this.fx == 0 || this.fy == 0) { // for horizontal or vertical scrolling if ( ( this.fx == -1 && x > -this.maxX ) || ( this.fx == 1 && x < 0 ) || ( this.fy == -1 && y > -this.maxY ) || ( this.fy == 1 && y < 0 ) ) { this.lastTime = now; this.shiftTo(this.lyr, x, y); this.on_scroll(x, y); } else { clearInterval(this.timerId); this.timerId = 0; this.shiftTo(this.lyr, this.endX, this.endY); this.on_scroll_end(this.endX, this.endY); } } else { // for scrolling at an angle (stop when reach end on one axis) if ( ( this.fx < 0 && x >= -this.maxX && this.fy < 0 && y >= -this.maxY ) || ( this.fx > 0 && x <= 0 && this.fy > 0 && y <= 0 ) || ( this.fx < 0 && x >= -this.maxX && this.fy > 0 && y <= 0 ) || ( this.fx > 0 && x <= 0 && this.fy < 0 && y >= -this.maxY ) ) { this.lastTime = now; this.shiftTo(this.lyr, x, y); this.on_scroll(x, y); } else { clearInterval(this.timerId); this.timerId = 0; this.on_scroll_end(this.x, this.y); } } } } dw_scrollObj.prototype.endScroll = function() { if (!this.ready) return; if (this.timerId) clearInterval(this.timerId); this.timerId = 0; this.lyr = null; } dw_scrollObj.prototype.on_scroll = function() {} dw_scrollObj.prototype.on_scroll_start = function() {} dw_scrollObj.prototype.on_scroll_end = function() {} This <div> layer positioned always at bottom left of the screen on scrolling (and calling some code from labpixies) works well in non-ie browsers, but in ie it requires the omission of the doctype declaration. Why? Is it possible to fix it so that it works with the doctype in ie? Code: <!doctype html> <html lang="en"> <head> <title></title> </head> <body> <div id="master" style="position: absolute; left: -120px; top: 11px; width: 350px; height: 0px"> <div id="menu" style="position: absolute; left: 117px; top: 12px"> <table border="0" width="18" cellspacing="0" cellpadding="0"> <tr> <td width="100%"> <a href="javascript:expand();" onfocus="this.blur()"> <img name="menutop" border="0" src="images/translate.gif" width="23" height="152"></a></td> </tr> </table> </div> <div id="screen" style="position: absolute; left: -138px; top: 12px; "> <table border="0" align="center" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px; border:1px solid #000000;"> <tr> <td style="padding-left:0px; height:0px; line-height:15px; background-color:#000000;"> <a href="http://www.labpixies.com" style="font-family: Arial,Verdana; font-size:12px; font-weight:bold; text-align:left; text-decoration:none; color:#ffffff;"> Gadget by LabPixies.com</a></td> </tr> <tr> <td> <iframe allowtransparency="true" align="top" scrolling="no" width="256" height="135" frameborder="0" src="http://cdn.labpixies.com/campaigns/babylon/babylon.html" target="_self"> </iframe></td> </tr> </table> </div> </div> <script type="text/javascript"> var sidemenu = document.getElementById('master'); function FixY() { screenWidth = screen.width; if (screenWidth == 1024) { var yside = 390; } else if (screenWidth == 1152) { var yside = 400; } else if (screenWidth == 1280) { var yside = 400; } else { var yside = 450; } if(document.body.scrollTop != "undefined") sidemenu.style.top = document.body.scrollTop+yside+'px'; else sidemenu.style.top = window.pageYOffset+yside+'px'; } setInterval("FixY()",100); </script> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </body> </html> My website is all up and running and I decided to put a new image viewing script on, I already had a revolving image script showing all my previous work before but the latest script has totally stopped the previous from working. You can view what I mean at www.actioncomputing.co.uk I am using 2 scripts both available on Dynamic Drive they are Lightbox image viewer 2.03a Ultimate Fade-in slideshow (v2.1) If anyone can tell me why this is I would be extremely gratefull. I figured if there was one it would be a Javascript but does anyone know of a countdown clock that almost looks like a counter/turnstile number row? Like this sorta: I've been looking for one where I have the numbers look just like that and 'push' upward as the times (days, minutes, seconds) go on. Hopefully someone knows of a script >< Thanks alot!!! Javascript for clock: Code: function showTime (dateObj) { thissecond=dateObj.getSeconds(); thisMinute=dateObj.getMinutes(); thisHour=dateObj.getHours(); // change thisHour from 24-hour time to 12-hour time by: // 1) if thisHour < 12 then set ampm to "a.m." otherwise set it to "p.m." var ampm = (thisHour < 12) ? "a.m." : "p.m."; // 2) subtract 12 from the thisHour variable thisHour = (thisHour > 12) ? thisHour - 12 : thisHour; // 3) if thisHour equals 0, change it to 12 thisHour = (thisHour == 0) ? 12 : thisHour; // add leading zeros to minutes and seconds less than 10 thisMinute = thisMinute < 10 ? "0"+thisMinute : thisMinute; thisSecond = thisSecond < 10 ? "0"+thisSecond : thisSecond; return thisHour + ":" + thisMinute + ":" + thisSecond + ampm; } HTML for page: Code: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- New Perspectives on JavaScript, 2nd Edition Tutorial 3 Tutorial Case The Chamberlain Civic Center Author: Date: Filename: ccc.htm Supporting files: back.jpg, calendar.css, calendar.js, ccc.css, ccc.jpg, logo.gif --> <title>The Chamberlain Civic Center</title> <link href="ccc.css" rel="stylesheet" type="text/css" /> <link href="calendar.css" rel="stylesheet" type="text/css" /> <script src="calendar.js" type="text/javascript"></script> </head> <body> <div id="head"> <script type="text/javascript"> calendar("March 25, 2011"); </script> <img src="ccc.jpg" alt="Chamberlain Civic Center" /> </div> <div id="links"> <table><tr> <td><a href="#">Home</a></td><td><a href="#">Tickets</a></td> <td><a href="#">Events</a></td><td><a href="#">Tour</a></td> <td><a href="#">Directions</a></td><td><a href="#">Hours</a></td> <td><a href="#">Packages</a></td><td><a href="#">Contact Us</a></td> </tr></table> </div> <div id="main"> <p id="firstp"><img src="photo.jpg" alt="" />March is another banner month at the Chamberlain Civic Center, with performances of the award-winning musical, <span>The Producers</span> by the Broadway Touring Company on March 4, 5, and 6. Tickets are going fast, so order yours today.</p> <p>Celebrate the season on March 11 with the Chamberlain Symphony and their special selection of classical music with Spring themes. The next day, March 12, exercise your mind by attending the Charles Dickens mystery <span>Edwin Drood</span>.</p> <p>Jazz lovers have a lot to celebrate in March with a visit from <span>The Jazz Masters</span> on the 17th. Then on March 24, enjoy the music of The Duke with <span>An Ellington Tribute</span> performed by the Jazz Company of Kansas City.</p> <p>Pins, bottles, plates, and chairs are flying at the Chamberlain Civic Center in March. <span>The Taiwan Acrobats</span> return with another amazing performance on Sunday, March 13. On March 20, the <span>Madtown Jugglers</span> get into the act with their unique blend of comedy, juggling, and madness.</p> <p>Enjoy a classical brunch every Sunday afternoon with music provided by the Carson Quartet. Seating is limited, so please reserve your table.</p> </div> <address> The Chamberlain Civic Center · 2011 Canyon Drive · Chamberlain, SD 57325 · (800) 555-8741 </address> </body> </html> CSS for page: Code: /* New Perspectives on JavaScript, 2nd Edition Tutorial 3 Tutorial Case Filename: ccc.css This file contains styles used in the ccc.htm file */ body {margin: 0px; background: white url(back.jpg) repeat-y scroll 820px 0px} #head {width: 750px; height: 150px; padding: 5px} #links {clear: right; width: 750px; padding: 0px} #links table {width: 750px; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; margin: 0px} #links table td {text-align: center; background-color: white; border: 1px solid black; letter-spacing: 5; padding: 2px} #links table a {text-decoration: none; color: rgb(223,29,29); width: 100%} #links table a:hover {color: white; background-color: rgb(223,29,29)} #main {width: 750px; font-family: Arial, Helvetica, sans-serif; padding: 10px} #main p {text-align: justify; font-size: 9pt} #firstp:first-line {font-variant: small-caps} #main img {float: right; margin: 0px 0px 10px 10px} #main p span {color: rgb(223,29,29)} address {width: 750px; font-size: 8pt; font-style: normal; color: rgb(223,29,29); font-family: Arial, Helvetica, sans-serif; text-align: center; border-top: 1px solid rgb(223,29,29); padding-bottom: 10px} Does anyone know how to put my clock into my HTM and CSS files to have it appear at the top left of the page? Please, help. Thanks. Hello, I'm somewhat new to JavaScript and for my website, I decided to make a clock for the website in this format: Saturday, October 17, 2009 5:56:14 p.m. The only issue is that it won't update every second. Below is the coding: External JavaScript: Code: function dateClock() { // Coding } setTimeout("dateClock()", 1000); HTML: Code: ... <script src="date.js" type="text/javascript"> </script> </head> <body> <script type="text/javascript"> document.write("<p style='margin:-15px 0px;background-color:black;position:fixed;padding:5px;'>"+Day+", "+Month+" "+date+", "+Year+"<br />"+Hour+":"+Minute+":"+Sec+" "+Suffix+"</p>"); </script> What can I do to make it update? Thanks. Hello to everyone . i have a clock from a javascript code and i want through drop down list to change the time location (city) the html part Code: <body onload="globalclock()"> <input type="text" size="50" id="globalclock" /> <select ......... onchange=""> <option value=''>select city</option> <option value='0'>Athens</option> <option value='1'>New York</option> .... .... <option value='36'>.........</option> </select> the only way to display the clock is to set values Code: //default clock dow="f"; cdate="a"; ctime="a"; city = 5; //its my default city when page load can anyone help me to manage this :-) Thankz Hello, I am trying to create a clock for my video game. I need to begin the clock at zero and count while the game is going. I need to have the clock count in standard minutes and seconds but not be based on the actual time of day. I am coding in javascript for an applet.
Hey all, I'm trying to sort a countdown clock for my website: http://www.cyber-technix.com/corps/index.php/ My vision of it was a transparent background, Blue text and a simple Day : Hour : Minute : Second Layout. I found a free .js countdown clock at http://www.hashemian.com/tools/javascript-countdown.htm Anyone got any better suggestions? I havn't used .js much so I may need some help implementing it if someone would be kind enough to help me out, thanks. Hello all! For the past few days I've been having trouble trying to figure out how to do something. I want to code a world population clock similar to the one here, but simpler: I want the user to be able to choose future years up to 2020 (just years, not months/days), and have the population grow by 1 percent each year. So far I have a code for the world population, but I have no clue where to begin in terms of making a list of the years with the option to increase the population. Could anyone point me in the right direction? I'd appreciate any help! Heres the code I have: <body> <script type="text/javascript"> function maind(){ startdate = new Date() now(startdate.getYear(),startdate.getMonth(),startdate.getDate(),startdate.getHours(),startdate.getM inutes(),startdate.getSeconds()) } function ChangeValue(number,pv){ numberstring ="" var j=0 var i=0 while (number > 1) { numberstring = (Math.round(number-0.5) % 10) + numberstring number= number / 10 j++ if (number > 1 && j==3) { numberstring = "," + numberstring j=0} i++ } numberstring=numberstring if (pv==1) {document.getElementById("worldpop").innerHTML=numberstring } } function now(year,month,date,hours,minutes,seconds){ startdatum = new Date(year,month,date,hours,minutes,seconds) var now = 5600000000.0 var now2 = 5690000000.0 var groeipercentage = (now2 - now) / now *100 var groeiperseconde = (now * (groeipercentage/100))/365.0/24.0/60.0/60.0 nu = new Date () schuldstartdatum = new Date (96,1,1) secondenoppagina = (nu.getTime() - startdatum.getTime())/1000 totaleschuld= (nu.getTime() - schuldstartdatum.getTime())/1000*groeiperseconde + now ChangeValue(totaleschuld,1); timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours( ),startdatum.getMinutes(),startdatum.getSeconds())",200) } window.onload=maind </script> Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>. </body> Hello, I would like help about my problem. I want to find the proper function to manage a clock . What I want to do is, when a city is selected from the drop down menu, the display of the clock must be changed depended by the city . Also to allow the user to vary the values of the three variables that control the display of a clock. <body onload="globalclock()"> <input type="text" size="50" id="globalclock" /> <select ......... onchange=""> <option value=''>select city</option> <option value='0'>Athens</option> <option value='1'>New York</option> .... .... <option value='36'>.........</option> </select> //default clock dow="f"; cdate="a"; ctime="a"; city = "22"; //its my default city when page load I use globalclock() function but with no results I'm trying to create a navigation bar with four elements. If the element is currently selected it will have a "red" background image, if it is one of the other 3, it will have a "black" background image. my four tabs are 'timetable, homework, notifications and sport' I tried making 8 functions like the 2 below Code: function setTimeRed() { document.getElementById("time").style.ClassName = 'timetable_r'; } function setTimeBlack() { document.getElementById("time").style.ClassName = 'time_r'; } And then four blocks like this: Code: function changeTimeButton() { var timePath = new String(); timePath = document.getElementById("timetable").style.backgroundImage; if(timePath == "url(assets/img/tabs/time_black.png)" || timePath == "") { setTimeRed(); setHomeBlack(); setNotiBlack(); setSportBlack(); } else { } } finally, my html has this: Code: <div id="tabbar"> <ul id="tabs"> <a href"#" onclick="changeTimeButton()"> <li id="timetable" class="time_b"> <p>Timetable</p> </li> </a> <a href"#" onclick="changeHomeButton()"> <li id="homework" class="home_b"> <p>Homework</p> </li> </a> <a href"#" onclick="changeNotiButton()"> <li id="notifications" class="noti_b"> <p>Notifications</p> </li> </a> <a href"#" onclick="changeSportButton()"> <li id="sport" class="sport_b"> <p>Sport</p> </li> </a> </ul> </div> It works once then does nothing. Why, and how would I go about fixing this?? Please help! |