mahi
mahi

Reputation: 13

How to pass iframe data to parent window

In a iframe div, I have several pages. whenever user scrolls within that div, I need to update the current page number in parent window (same origin).

To achieve this, I have binded a scroll event to the div element and made the calculations to get current page number in iframe. But, struck how to pass this data to parent window.

Upvotes: 1

Views: 877

Answers (2)

Alexis
Alexis

Reputation: 5831

You can create a function in your parent page.

Parent

function parentcalc(data)
{
 //use your data
}

And call this function in the child like this

iframe

parent.parentcalc(mydata);

Upvotes: 1

Quentin
Quentin

Reputation: 943108

You can access the parent frame through the parent global variable.

Upvotes: 1

Related Questions