Reputation: 873
external .js file not loading, while inline does work. here is my JS file,I'm pretty sure its a tiny mistake, but I can't seem to find it. I read somewhere that it might have to do with the utf definition, but i saved all files with utf-8. Thank you
<SCRIPT LANGUAGE="JavaScript">
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m = checkTime(m);
s = checkTime(s);
h = checkTime(h);
document.getElementById("seconds").innerHTML = s;
document.getElementById("minutes").innerHTML = m;
document.getElementById('hours').innerHTML = h;
var t = setTimeout(function(){startTime()},500);
}
function checkTime(i) {
if (i<10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
and here is my html file
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="min.js"></script>
<link rel="stylesheet" href="stylesheet.css">
</head>
<body style="background-color:#444657;" onload="startTime()">
<table id="table1">
<tr>
<th><a href="http://www.facebook.com"target="_blank">facebook</a></th>
<th><a href="http://www.expedia.com" target="_blank">expedia</a></th>
<th><a href="http://www.planefinder.net" target="_blank">planefinder</a></th>
<th><a href="http://www.soundcloud.com" target="_blank">Soundcloud</a></th>
<th><a href="http://www.youtube.com" target="_blank">Youtube</a></th>
<th><a href="http://www.gmail.com" target="_blank">Gmail</a></th>
<th><a href="http://www.google.com" target="_blank">GOOGLE</a></th>
</tr>
</table>
<div id="div2" onload="startTime()">
<p id="hours"></p>
<p> :</p>
<p id="minutes"></p>
<p> :</p>
<p id="seconds"></p>
</div>
</body>
</html>
I'm pretty sure its a tiny mistake, but I can't seem to find it.
Upvotes: 1
Views: 106
Reputation: 25373
If the code in your first code block is in the file min.js (a separate .js file) than you don't need the script tags.
Remove those tags and those functions should be accessible, but note they are added to the global namespace.
Upvotes: 4