1. index.jsp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <frameset cols="25%,0,75%"> <frame src="/testForm/left.jsp" name="left"> <frame src="/testForm/middle.jsp" name="middle"> <frame src="/testForm/right.jsp" name="right"> </frameset> </html>
2. left.jsp
<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> left </body> </html>
3. middle.jsp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> middle </body> </html>
4. right.jsp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript"> function testFormTarget(){ var oldAction = fm.action; var oldTarget = fm.target; fm.action="/testForm/generationInfo.jsp"; fm.target="middle"; fm.submit(); fm.action=oldAction; fm.target=oldTarget; } </script> </head> <body> <form name="fm" action="/testForm/left.jsp" target="left"> name:<input type="text" name="name" value="" readonly="readonly"><br> age:<input type="text" name="age" value="" readonly="readonly"><br> sex:<input type="text" name="sex" value="" readonly="readonly"><br> address:<input type="text" name="address" value="" readonly="readonly"><br> <br> <!-- <button onclick="testFormTarget()">显示信息</button> --> <input type="button" value="显示信息" onclick="testFormTarget()"> </form> </body> </html>
5. generationInfo.jsp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <script type="text/javascript"> parent.right.fm.name.value = "guxianyang"; parent.right.fm.age.value = 25; parent.right.fm.sex.value = "男"; parent.right.fm.address.value = "安徽寿县"; </script> </body> </html>