问题
I have a form that takes in a userID. It is located on a page with 3 frames. How would I open two different .jsp's in the frames after the user submits their ID?
回答1:
In your <form/>
Tag use the attribute target="_parent"
to break up the current frame set. Then in your response you can send a new frameset so that all three frames are reloaded.
Update to clarify it a little bit:
form
tag without target
attribute:
The user submits the form. The server processes the form data and sends a response, i.e. a welcome page. The browser shows this response page in the same frame.
form
tag with target="_parent"
: The user submits the form. Ther server processes the form data and sends a response. The difference here is, that the browser replaces the whole frameset with the server respone. This gives you the chance to update the other frames.
But in this case you have to change the server response. If it is still the welcome page then the browser will show only that page and no other frames. The server response should be a frameset similar to the original frameset. But you can replace the three frame URLs with different URLs:
Original frameset:
<frameset>
<frame src="login.jsp" name="frame1" />
<frame src="contentA.jsp" name="frame2" />
<frame src="contentB.jsp" name="frame3" />
</frameset>
As a response to the user login you send a new frameset
<frameset>
<frame src="welcome.jsp" name="frame1" />
<frame src="contentC.jsp" name="frame2" />
<frame src="contentD.jsp" name="frame3" />
</frameset>
来源:https://stackoverflow.com/questions/7841824/how-to-perform-multiple-actions-with-one-form