View Full Version : Live date script

03-07-2010, 02:43 AM

Does this script conflict with other java scripts? I've cou and pasted the above script to notepad then to my webpage and nothing happens. I created a new page and it works on it, but that's not what I want.
Here's a test page on my site: www.noahsvideo.com/time1.html
Any help would be gratefully appreciated

03-07-2010, 03:03 AM
Yes. Many older scripts (and this one qualifies for that) as well as some more recent ones use the onload function of the window or the body. Unless certain measures of one sort or another are taken, only one script will end up having the use of onload. There is at least one other script on your page that uses onload and it has taken onload away from the Live Date script.

There are various solutions, for this script in this case I would suggest getting rid of (highlighted):

<body onLoad="goforit()">

and then in this script add (also highlighted):

. . . etElementById("clock").innerHTML=cdate
if (!document.all&&!document.getElementById)
function goforit(){
if (document.all||document.getElementById)

if (window.addEventListener){
window.addEventListener('load', goforit, false);
else if (window.attachEvent){
window.attachEvent('onload', goforit);


That's it!