为什么我在html中可以正常用javascript,然后复制到jsp中就不行了呢?

oDaBao 2012-11-18 05:07:12
主要是想实现一个浏览器状态栏弹出文字的特效,JSP服务器用的是tomcat7,jsp用myeclipse编的。

jsp文件的代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>网站技术测试页面</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script >
var msg="欢 迎 光 临 !";
var interval=150;
var subLen=1;
function Scroll(){
len=msg.length+2;
window.status=msg.substring(0, subLen);
subLen++;
if(subLen >len){
subLen=1;
window.status="";
window.setTimeout("Scroll()", interval);

}
else
window.setTimeout("Scroll()", interval);
}

Scroll();

</head>

<body>

</body>
</html>




html代码:
<html>
<head>


<title>网站技术测试页面</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script >
var msg="欢 迎 光 临 鲁 东 大 学 新 闻 中 心 !";
var interval=150;
var subLen=1;
function Scroll(){
len=msg.length+2;
window.status=msg.substring(0, subLen);
subLen++;
if(subLen >len){
subLen=1;
window.status="";
window.setTimeout("Scroll()", interval);

}
else
window.setTimeout("Scroll()", interval);
}

Scroll();

</head>

<body>

</body>
</html>


请大侠赐教。
...全文
297 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qinzi_2013 2012-11-21
  • 打赏
  • 举报
回复
引用 4 楼 xhmlwaf 的回复:
JSP里JS的写法和HTML应该是一样的。注意格式就好了。。
同意
xhmlwaf 2012-11-21
  • 打赏
  • 举报
回复
JSP里JS的写法和HTML应该是一样的。注意格式就好了。。
_Laity 2012-11-21
  • 打赏
  • 举报
回复
JSP里JS的写法和HTML不同吧。 楼上人说了 照做试试 。
zhangzhao608 2012-11-18
  • 打赏
  • 举报
回复
同意楼上。。。还有JSP写的事件是function啊~
NoTargetException 2012-11-18
  • 打赏
  • 举报
回复
你的jsp好像没有</script>结束符啊 还有最好写清楚<script language="javascript">

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧