Jsp nested iframe: submit the form from iframe and pass the value to the outer layer. nested iframe

Source: Internet
Author: User

Jsp nested iframe: submit the form from iframe and pass the value to the outer layer. nested iframe

Today, the Code encountered such a problem due to iterative metadata change.

I just want to jump to the whole page after submitting in iframe and pass the value in iframe to the outer jsp

Probably like this.

Outer a. jsp

<div id="d"></div><iframe src="b.jsp" name="listresult" width="100%" height="100%" frameborder="0"></iframe>         

 

Inner Layer B. jsp

<Form action = '... do'>...
<Input type = 'did' name = 'A' value = 'A'/> <input type = 'submit 'value = 'Submit'/> </form>

 

 

So take it for granted that the start code is

I plan to use js to assign values and write a js in B. jsp.

$('#d').val('<s:property value="a"/>');

Although the value of the hidden domain can be obtained, the outer value is not passed.

Result failed

 

 

Then various searches finally found a feasible method.

The idea is to write a method in B. jsp to call the js method in a. jsp, implement the jump, and then assign a value in a. jsp.

Good Code

B. jsp

window.parent.f1('<s:property value="a"/>');

 

A. jsp

function f1(value){        window.parent.document.getElementById('main').src = '....do?a='+value;}

 

 

---------------------------- Separation line ---------------------------------------

 

The following information is found on the Internet:Window. parent.

 

Good reception

 

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.