问题是这样的:
我要在index.jsp
- Java code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import = "java.sql.*,com.xzh.util.*"%> <% Boolean isLogin = (Boolean)session.getAttribute("isLogin"); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; conn = DBUtil.getConn(); pstmt = DBUtil.getPstmt(conn,"select * from t_msg"); rs = pstmt.executeQuery(); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> . . . <script type="text/javascript" src="./global.js"></script> . . . <form action="addMsg.jsp" name="note" method="post" onsubmit="return check()"> . . .
- JScript code
function a(){ window.setInterval("b()",1000); } function b(){ var objTime = document.getElementById("time"); var time = objTime.innerHTML; time = time - 1; objTime.innerHTML = time; if(time==0){ var path = document.getElementById("path"); window.location=path; } } function check(){ var objForm = document.forms[0]; if(objForm.username.value.length==0){ alert("用户名不能为空!"); return false; } if(objForm.title.value.length==0){ alert("留言标题不能为空!"); return false; } if(objForm.email.value.length==0){ alert("电子邮件不能为空!"); return false; } if(objForm.iqcq.value.length==0){ alert("iqcq不能为空!"); return false; } if(objForm.mypage.value.length==0){ alert("我的主页不能为空!"); return false; } if(objForm.content.value.length==0){ alert("留言内容不能为空!"); return false; } return true; } function check_user(){ var objForm = document.forms[0]; if(objForm.password.equals(objForm.password_2)){ alert("密码不一致!"); return false; } if(objForm.id.value.length==0){ alert("用户名不能为空!"); return false; } if(objForm.password.value.length==0){ alert("密码不能为空!"); return false; } if(objForm.username.value.length==0){ alert("昵称不能为空!"); return false; } if(objForm.email.value.length==0){ alert("电子邮件不能为空!"); return false; } if(objForm.iqcq.value.length==0){ alert("iqcq不能为空!"); return false; } return true; }
但是每次都不能调用global.js文件而直接跳转到一下个页面,这是为什么啊?
------解决方案--------------------
远的咱不说吧,就说你现在看到的这个贴子,head就加载了两个js
- JScript code
<script type="text/javascript" src="/u/t5/t5.js"></script> <script type="text/javascript" src="http://counter.csdn.net/a/js/AreaCounter.js"></script>