html调用js调用不了

来源:百度知道 编辑:UC知道 时间:2024/06/23 14:19:47
我想在网页中调用js程序来显示当前时间。问题是怎么改我都调用不出来。
麻烦大家帮我看下,html和js里的程序我都写在下面,麻烦大家找下错误帮我改下。说明原因就更好了!
<html>
<head>
<title>当前时间</title>
<script language=javascript src="js/RenYuan.js"></script>
</head>
<body onload="ShowTime()">
<font color="#ff0000" size="3">当 前 时 间:<label id="ALARM"></LABEL></font>
</body></html>
这个是js文件夹下的RenYuan.js文件程序。
function ShowTime()
{document.getElementById("ALARM").innerText = (new Date()).toLocaleDateString()+ " " + (new Date()).toLocaleTimeString();
TimerID = setTimeout("ShowTime()",1000);
}
那个分号改了还是一样调用不出来,希望大家自己试验一下~~

1.在你的要调用的html文件中,通过<script src=''></script>这个标签填写上正确你的JS文件路径就可以了,这里上代码:
调用test.js文件,显示提示。
<html>
<body>
调用test.js文件
<script language="JavaScript" src="test.js">
</script>
</body>
</html>
test.js的文件内容如下:
alert("这是被调用的语句。")

2.在html的内部中去调用写在html网页中就行:
<script>
alert('这是被调用的语句');

</script>

3.通过a等一些html标签来表示
<body>
<a href="javascript:alert('这是被调用的语句');">aaaaa</a>
</body>

....()).toLocaleTimeString();最后的分号,改成半角的。
<html>
<head>
<title>当前时间</title>
<script language=javascript>
function ShowTime()
{document.getElementById("ALARM").innerText = (new Date()).toLocaleDateString()+ " " + (new Date()).toLocaleTimeString();
TimerID = setTimeout("S