书上的例子,不知为什么我打开这个jsp就是一个空白的页面,什么都没有,把script注掉就能显示一个页面,应该是javascript写的有问题?帮我看看
JSP:<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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>
<base href="<%=basePath%>">
<script type="text/javascript" src="js/script01.js"/>
<title>My JSP 'index.jsp' starting page</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">
-->
</head>
<body>
<div align="center">
<a href="linkPage.html">
<img src="image/a.gif" width="400" height="75" id="adBanner" border="0" alt="ad banner"/></a>
</div>
This is my JSP page. <br>
</body>
</html>JAVASCRIPT:window.onload = initBannerLink;var thisAd = 0;function initBannerLink() {
if (document.getElementById("adBanner").parentNode.tagName == "A") {
document.getElementById("adBanner").parentNode.onclick = newLocation;
}
rotate();
}function newLocation() {
var adURL = new Array("sina.com", "163.com", "sohu.com");
document.location.href = "http://www." + adURL[thisAd];
return false;
}function rotate() {
var adImages = new Array("image/a.gif", "image/b.gif", "image/c.gif");
thisAd++;
if (thisAd == adImages.length) {
thisAd = 0;
}
document.getElementsByTagName("adBanner").src = adImages[thisAd];
setTimeout(rotate, 3 * 1000);
}
JSP:<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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>
<base href="<%=basePath%>">
<script type="text/javascript" src="js/script01.js"/>
<title>My JSP 'index.jsp' starting page</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">
-->
</head>
<body>
<div align="center">
<a href="linkPage.html">
<img src="image/a.gif" width="400" height="75" id="adBanner" border="0" alt="ad banner"/></a>
</div>
This is my JSP page. <br>
</body>
</html>JAVASCRIPT:window.onload = initBannerLink;var thisAd = 0;function initBannerLink() {
if (document.getElementById("adBanner").parentNode.tagName == "A") {
document.getElementById("adBanner").parentNode.onclick = newLocation;
}
rotate();
}function newLocation() {
var adURL = new Array("sina.com", "163.com", "sohu.com");
document.location.href = "http://www." + adURL[thisAd];
return false;
}function rotate() {
var adImages = new Array("image/a.gif", "image/b.gif", "image/c.gif");
thisAd++;
if (thisAd == adImages.length) {
thisAd = 0;
}
document.getElementsByTagName("adBanner").src = adImages[thisAd];
setTimeout(rotate, 3 * 1000);
}
解决方案 »
- 关于jquery的hover事件
- setTimeout()方法使用问题
- 有关给一个对象添加事件的问题
- 搭建GWT环境的问题
- 一个简单但又有难度的正则问题!请大家帮忙,我都想了几天还是不行!分不多40全给了!
- 再次 请教formlist 移动的问题? 要求是从list1 可以复制到 list2合list3去 list1内容不变的情况下可以多行一起添加删除
- 菜鸟纹一个很简单的JavaScript问题。
- 问一个用Javascript把表格输出到Excel的问题。
- 请教一个模态窗口的问题
- JavaScript 读取 cookie 中的内容确定页面调用的 CSS 可以实现吗?
- asp中使用javascript语句?
- 请高手帮忙把一个解密的JS代码,改成加密的
改成
<script type="text/javascript" src="js/script01.js"></script>
if (document.getElementById("adBanner").parentNode.tagName == "A") {
document.getElementById("adBanner").parentNode.onclick = newLocation;
}
rotate();
}function newLocation() {
var adURL = new Array("sina.com", "163.com", "sohu.com");
document.location.href = "http://www." + adURL[thisAd];
return false;
}
var tid;
function rotate() {
clearTimeout(tid);
var adImages = new Array("image/a.gif", "image/b.gif", "image/c.gif");
thisAd++;
if (thisAd == adImages.length) {
thisAd = 0;
}
document.getElementById("adBanner").src = adImages[thisAd];
tid = setTimeout(rotate, 3 * 1000);
}