test.jsp<%@ page contentType="text/html;charset=GBK"%>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<form action ="test2.jsp">
<input type="text" name="txt" id="txtid" >
<input type="hidden" name="hid" id="hidid" >
<input type="submit" value="Test">
</form>
</BODY>
</HTML>
test2.jsp<%@ page contentType="text/html;charset=GBK"%>
<html>
<%
String name = request.getParameter("Name");
out.println("<script> alert('出错了');history.go(-1);</script>");
%>
<head></head>
<body>
<script type="text/javascript">
alert("我还在呢");
location.href='test2.jsp';
</script>
ffffffffff
</body>
</html><script type="text/javascript">
alert("我还在呢");
location.href='test2.jsp';
</script>
ffffffffff这段代码执行的吗,我试没用弹出(我还在呢)!但上次我做的时候(没有<script type...>.....<script>而是往数据库里插入数据,它执行了),这是为什么?
history.go(-1)扫行,后在的代码到底还运行吗
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<form action ="test2.jsp">
<input type="text" name="txt" id="txtid" >
<input type="hidden" name="hid" id="hidid" >
<input type="submit" value="Test">
</form>
</BODY>
</HTML>
test2.jsp<%@ page contentType="text/html;charset=GBK"%>
<html>
<%
String name = request.getParameter("Name");
out.println("<script> alert('出错了');history.go(-1);</script>");
%>
<head></head>
<body>
<script type="text/javascript">
alert("我还在呢");
location.href='test2.jsp';
</script>
ffffffffff
</body>
</html><script type="text/javascript">
alert("我还在呢");
location.href='test2.jsp';
</script>
ffffffffff这段代码执行的吗,我试没用弹出(我还在呢)!但上次我做的时候(没有<script type...>.....<script>而是往数据库里插入数据,它执行了),这是为什么?
history.go(-1)扫行,后在的代码到底还运行吗
String name = request.getParameter("Name");
out.println("<script> alert('出错了');history.go(-1);</script>");
%>
不往后走了,
<script type="text/javascript">
alert("我还在呢");
location.href='test2.jsp';
</script>
接着往后走沙发!~
out.write("<html>\r\n");
out.write(" "); String name = request.getParameter("Name");
out.write("\r\n");
out.write(" "); if(name==null){
out.write("\r\n");
out.write(" <script type=\"text/html\">\r\n");
out.write(" \t alert(\"出划\");\r\n");
out.write(" \t history.go(-1);\r\n");
out.write(" </script>\r\n");
out.write(" "); }
//out.println("<script type='text/javascript'> alert();hisory.go(-1)</script>");
out.write("\r\n");
out.write(" \r\n");
out.write(" <head></head>\r\n");
out.write(" <body>\r\n");
out.write(" \t <script type=\"text/javascript\">\r\n");
out.write(" \t \t alert(\"我还在呢\");\r\n");
out.write(" \t \t return ;\r\n");
out.write(" \t \t location.href='test2.jsp';\r\n");
out.write(" \t </script>\r\n");
out.write(" \t "); out.println("ssssssssssss");
out.write("\r\n");
out.write(" \t ffffffffff\r\n");
out.write(" </body>\r\n");
out.write("</html>");
还不明白这两者的区别?
刚才说的不清楚,接着往后走是指'test2.jsp'; 往这里走
这是因为这时候你没有location.href='test2.jsp'; 这条了,所以不会跳转到任何地方从而结束程序的运行,所以数据库插入数据执行了