How to add javasctipy clock to cmsimple?

General questions about CMSimple
Post Reply
rain-13

How to add javasctipy clock to cmsimple?

Post by rain-13 » Tue Mar 17, 2009 9:01 pm

How to add this code into cmsimple? if I save my code as html, then it works, but if I copy function to cmsimple from <script type="text/javascript"> to </script> then it don't work, how could I add it in cmsimple thatway it works?

Code: Select all

<html>
<head>
<script type="text/javascript">
function startTime()
{
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('txt').innerHTML='<font color="#00'+d2h2(s)+'00"><b>'+d2h(h)+":"+d2h(m)+":"+d2h(s)+'</font><b>';
t=setTimeout('startTime()',500);
}

function d2h(d) {return d.toString(16);}
function d2h2(d) {return (d.toString(16))*10;}

function checkTime(i)
{
if (i<10)
  {
  i="0" + i;
  }
return i;
}
</script>
</head>

<body onload="startTime()">
<div id="txt"></div>
</body>
</html>


Tata
Posts: 3588
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: How to add javasctipy clock to cmsimple?

Post by Tata » Wed Mar 18, 2009 6:46 am

I am not sure, but you have there the call "onload". CMSimple has its own call "onload". This may cause the conflict. I remember to have this type of script put on a simple html page in root and then called it to a newsbox in the template.
Another way is to use one of hundreds free scripts called from their servers. E.g.: http://www.clocklink.com .
Generated code then may be placed in your template or a particular page after your desire.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply