代码部分:
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<script language="javascript">
opener.location=opener.location;window.close();
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<jsp:useBean id="wu" scope="page" class="wu.jdbc" /><%
Connection con = wu.getConn() ;
Statement stmt = con.createStatement() ;
String content = request.getParameter("content") ;
content = wu.ex_chinese(content) ;
String qq = request.getParameter("qq") ;
qq = wu.ex_chinese(qq) ;
String email = request.getParameter("email") ;
email = wu.ex_chinese(email) ;
String url = request.getParameter("url") ;
url = wu.ex_chinese(url) ;
String xm = request.getParameter("yhm") ;
xm = wu.ex_chinese(xm) ;
String msg = "您在留言成功。" ;
String sql = "insert into liuyan_temp(url,ip,email,qq,sj,content,xm) values('"+url+"','"+request.getRemoteHost()+"','"+email+"','"+qq+"','"+wu.gettime()+"','"+content+"','"+xm+"')" ;
stmt.executeUpdate(sql) ;
try {
stmt.close();
con.close();
}
catch (Exception ex) {}
%>
<body>
<p> </p><table border="1" align="center" cellspacing="0" bordercolorlight="000000" bordercolordark="FFFFFF" bgcolor="E0E0E0">
<tr>
<td> <table border="0" bgcolor="#0066CC" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td width="342"><font color="FFFFFF">¤<%=msg%></font></td>
<td width="18"> </td>
</tr>
</table>
<table border="0" width="100%" cellpadding="4">
<tr>
<td width="59" align="center" valign="top"><font face="Wingdings" color="#FF0000" style="font-size:32pt">L</font></td>
<td width="269">
<p><%=msg%></p>
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top"> <input type="button" name="ok" value="关闭窗口" onclick="window.close()">
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
问题如下:
1.一个javascript函数放在页面的HEAD部分里面与放在BODY下面有什么区别?在执行顺序上面有区别吗? 比如放在HEAD部分的先执行,在加入JS函数时需要注意这些方面的问题吗?2.假如上面的代码页面是C页面原理是A页面上的连接大开了一个窗口B页面(好象是摸态窗口,A中间出现个小窗口),在B页面填好数据转到C页面(看不到这个页面,自动执行一些代码,然后关闭窗口,回到A页面并刷新数据)
请问上面的代码是怎么执行的???怎么如此奇怪,自动的把代码都执行了,而且回到A页面,请问这些代码的执行顺序(包括HTML,JSP,和javascript函数)
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<script language="javascript">
opener.location=opener.location;window.close();
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<jsp:useBean id="wu" scope="page" class="wu.jdbc" /><%
Connection con = wu.getConn() ;
Statement stmt = con.createStatement() ;
String content = request.getParameter("content") ;
content = wu.ex_chinese(content) ;
String qq = request.getParameter("qq") ;
qq = wu.ex_chinese(qq) ;
String email = request.getParameter("email") ;
email = wu.ex_chinese(email) ;
String url = request.getParameter("url") ;
url = wu.ex_chinese(url) ;
String xm = request.getParameter("yhm") ;
xm = wu.ex_chinese(xm) ;
String msg = "您在留言成功。" ;
String sql = "insert into liuyan_temp(url,ip,email,qq,sj,content,xm) values('"+url+"','"+request.getRemoteHost()+"','"+email+"','"+qq+"','"+wu.gettime()+"','"+content+"','"+xm+"')" ;
stmt.executeUpdate(sql) ;
try {
stmt.close();
con.close();
}
catch (Exception ex) {}
%>
<body>
<p> </p><table border="1" align="center" cellspacing="0" bordercolorlight="000000" bordercolordark="FFFFFF" bgcolor="E0E0E0">
<tr>
<td> <table border="0" bgcolor="#0066CC" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td width="342"><font color="FFFFFF">¤<%=msg%></font></td>
<td width="18"> </td>
</tr>
</table>
<table border="0" width="100%" cellpadding="4">
<tr>
<td width="59" align="center" valign="top"><font face="Wingdings" color="#FF0000" style="font-size:32pt">L</font></td>
<td width="269">
<p><%=msg%></p>
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top"> <input type="button" name="ok" value="关闭窗口" onclick="window.close()">
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
问题如下:
1.一个javascript函数放在页面的HEAD部分里面与放在BODY下面有什么区别?在执行顺序上面有区别吗? 比如放在HEAD部分的先执行,在加入JS函数时需要注意这些方面的问题吗?2.假如上面的代码页面是C页面原理是A页面上的连接大开了一个窗口B页面(好象是摸态窗口,A中间出现个小窗口),在B页面填好数据转到C页面(看不到这个页面,自动执行一些代码,然后关闭窗口,回到A页面并刷新数据)
请问上面的代码是怎么执行的???怎么如此奇怪,自动的把代码都执行了,而且回到A页面,请问这些代码的执行顺序(包括HTML,JSP,和javascript函数)
http://dotnet.aspx.cc/ShowDetail.aspx?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
window.close();//关闭自己
如果调用页面对象,应当在对象生成后才能调用。这句话是什么意思?
为什么JSP代码先运行而JS代码最后运行