1
外部.js文件未加載,而內聯確實有效。 這裏是我的JS文件,我很確定它是一個小錯誤,但我似乎無法找到它。我在某處讀到它可能與utf定義有關,但我用utf-8保存了所有文件。 謝謝外部JS未加載到我的HTML文件中?
<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>
,這裏是我的html文件
<!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>
我敢肯定它是一個很小的錯誤,但我似乎無法找到它。
腳本被命名爲'min.js'? – Claies