Zain Asad
Zain Asad

Reputation: 11

using iframes to cross data exchanging

I am using iframes in aspx page.

  1. Page1.aspx has drop down list and button.I will be passing the drop down list selected values in the button click event to Page2.aspx iframe1.

2.In the Page2.aspx I have 2 iframes. iframe1 gets parameters from page1.aspx and it has controls and button.In the button click event of iframe1 I want to pass the values of iframe1 to iframe2.

3.If I change the control values in iframe1 and click the button in iframe1,iframe2 should get refreshed.

Any suggestions please.

Upvotes: 1

Views: 32

Answers (1)

Ludovic Feltz
Ludovic Feltz

Reputation: 11916

You can use postMessage to pass information to an iframe:

1) in you receiver just add a listener:

window.addEventListener("message", receiveMessage, false);

function receiveMessage(event)
{
  if (event.origin !== "http://example.org:8080")
    return;

  // ...
}

2) then in you sender

dstIframe.postMessage("Your message", "https://host.com");

You have to use give in parameter the host who send the message and check in the receiver if the host is the one you want to receive information from.

Upvotes: 1

Related Questions