为什么我在html中可以正常用javascript,然后复制到jsp中就不行了呢?
主要是想实现一个浏览器状态栏弹出文字的特效,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>
请大侠赐教。