PDA

View Full Version : Live date script



egghead2000
03-07-2010, 02:43 AM
http://www.dynamicdrive.com/dynamicindex6/clock3.htm

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

jscheuer1
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
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

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

</script>

That's it!