Vic_mackey
May 12th 2008, 2:01 am
Okay I have a problem with this. A design company sent me a new website I'd had done, but they've used javascript in the code itself rather than call it from external files. Its just a javascript to show the current time.
To start with it looked like this:
<td height="15" class="white-medium-text"><script language="javascript" type="text/javascript">
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
var runTime = new Date();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var dn = "AM";
if (hours >= 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = "<b>"+ hours + ":" + minutes + ":" + seconds + " " + dn + "</b>";
document.getElementById('clock').innerHTML = movingtime;
setTimeout("funClock()", 1000)
}
window.onload = funClock;
// End -->
</script>
<script language="javascript" type="text/javascript">
<!-- Begin
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
var runTime = new Date();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var dn = "AM";
if (hours >= 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = hours + ":" + minutes + ":" + seconds + " " + dn ;
document.getElementById('clock').innerHTML = movingtime;
setTimeout("funClock()", 1000)
}
window.onload = funClock;
// End -->
</script>
<span id=clock style="position:relative;"></span>
So its two javascripts. I put the first one in an external file and changed the first part to:
<td height="15" class="white-medium-text"><script type="text/javascript" src="clock.js"></script>
It worked fine like this. Now when I put the 2nd part into another external script, the clock isn't displaying. I dont want to leave the page full of javascript code, I'd prefer to get the 2nd part in an external file. Can anyone say why it is not working?
thanks
To start with it looked like this:
<td height="15" class="white-medium-text"><script language="javascript" type="text/javascript">
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
var runTime = new Date();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var dn = "AM";
if (hours >= 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = "<b>"+ hours + ":" + minutes + ":" + seconds + " " + dn + "</b>";
document.getElementById('clock').innerHTML = movingtime;
setTimeout("funClock()", 1000)
}
window.onload = funClock;
// End -->
</script>
<script language="javascript" type="text/javascript">
<!-- Begin
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
var runTime = new Date();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var dn = "AM";
if (hours >= 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = hours + ":" + minutes + ":" + seconds + " " + dn ;
document.getElementById('clock').innerHTML = movingtime;
setTimeout("funClock()", 1000)
}
window.onload = funClock;
// End -->
</script>
<span id=clock style="position:relative;"></span>
So its two javascripts. I put the first one in an external file and changed the first part to:
<td height="15" class="white-medium-text"><script type="text/javascript" src="clock.js"></script>
It worked fine like this. Now when I put the 2nd part into another external script, the clock isn't displaying. I dont want to leave the page full of javascript code, I'd prefer to get the 2nd part in an external file. Can anyone say why it is not working?
thanks