书上的例子,不知为什么我打开这个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);
}

解决方案 »

  1.   

    <script type="text/javascript" src="js/script01.js"/>
    改成
    <script type="text/javascript" src="js/script01.js"></script>
      

  2.   

    js也有错,改成: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;
    }
    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);
    }
      

  3.   

    <script> <iframe>等 必须要有结束标签
      

  4.   

    图片显示不了,我的路径有问题?我的js目录和image目录是平级的,都在webRoot目录下我的jsp写成image/a.gif可以看到图片js里面写的这个路径是不是不对?显示不了
      

  5.   

    原来的js是错的,js改成我上面的,应该可以显示
      

  6.   

    可以了,多谢!再问一下:是不是这样,我的js文件无论放在哪里,在js里都可以用image/a.gif定位图片?这个路径对jsp而言正确就可以了?