我很抱歉提出这样一个愚蠢的问题,但我似乎无法让我的Javascript被执行。我从完整的页面切换到一个简单的例子,以确保我没有做任何棘手的事情,我仍然无法让JS工作。我已经保存在一个文件下面的代码名为我的服务器上的index.html:Javascript未执行
<%@page import="index.jsp" %>
<html>
<head>
<title>Hello World</title>
</head>
<body>
Hello World!<br/>
<script type="text/JavaScript" src="index.jsp">
</script>
Still hello world!
<script type="text/JavaScript">
out.println(" Your IP address is " + request.getRemoteAddr());
alert("Welcome to the boost converter site");
</script>
</body>
</html>
而我所看到的,当我去的网页是:
Hello World
Still Hello World
在index.jsp文件,我有:
function InitPage(){
out.println("Your IP address is " + request.getRemoteAddr());
}
我知道解决的办法是出奇的简单,但我一直没能拿出的代码来修复此行。我一直在将示例代码复制到我的页面,以查看其他人的JS是否正确执行,但我也没有得到。很确定服务器运行Tomcat。
感谢,
克雷格
试试这里的示例代码http://www.w3schools.com/js/js_functions.asp – 2012-08-07 19:29:06