JSP submitted to the original window

Source: Internet
Author: User

There are two pages, A. jsp and B. jsp. A. jsp has a submit operation, and B. jsp is the action of the submit operation,

In. add <base target = "_ Self"> to the JSP page. On ie6.0,. the content of the JSP window is changed to B. JSP, and. JSP content addition will be overwritten, but a new window will pop up on ie7.0.

How can we avoid a new window after submitting a. jsp? What about a. jsp? Here are a few simple methods

I. implement it on the. jsp page

A. jsp

<form name="form1" method="post" target="submit2Here" action="B.jsp">//your html code</form><iframe name="submit2Here" style='display:none'></iframe>
 
In this way, the content of B. jsp will be put in the IFRAME named submit2here.
In Js of B. jsp,
You can use window. Parent to obtain the window of a. jsp;
You can use plain parent.doc ument to obtain the document of a. jsp;
Window. Parent. afunction () can be used to call the js method afunction defined in A. jsp;
In this way, you can use js to operate the elements and methods in A. jsp.
2. Use another page C. jsp
C.jsp
 <iframe name="submitPage"            src="A.jsp"            width="900" height="630" frameborder="no" border="0" marginwidth="0" marginheight="0"  allowtransparency="yes" ></iframe> <iframe name="submit2Here" style='display:none'></iframe>
A.jsp
<form name="form1" method="post" target="submit2Here" action="B.jsp">//your html code</form>
In this way, the content of B. jsp will be put in the IFRAME named submit2here in C. jsp.
In Js of B. jsp,
You can obtain the window of a. jsp by using upload parent.doc ument. Frames ['submitpage']. contentWindow;
You can use alert(paipaiparent.doc ument. Frames ['submitpage']. contentWindow. Name );
Or alert(registry.parent.doc ument. Frames [0]. contentWindow. Name); try
You can obtain the document of a. jsp using the optional parameter parent.document.frames['submitpage'{.content}w.doc ument;
Use callback parent.doc ument. Frames ['submitpage']. contentWindow. afunction () to call the js method afunction defined in A. jsp;
In this way, you can use js to operate the elements and methods in A. jsp.
Use the contentWindow attribute, which is compatible with browsers such as IE and Firefox.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.