views:

32

answers:

2

Hi Guys,

I have data in a iframe. When a user performs an action - I want this want this data to be collated and sent "inside" another iframe inside this iframe.

I have having a bit trouble achieving this and was wondering whether its possible and if it is, how I can do it ?

Thx

+1  A: 

I has this problem a while ago and did not find any solution. As I remember, you cannot control an inner frame from its owner due to some security concerns.

Later Edit: you might be able to synchronize them by using an intermediate component (such a database) - this is how I ended with my issue

thelost
+1  A: 

A quick solution would be to pass instructions (actions, variables, etc) as query variables in a url. You can use your outside script to change the iFrame reference and a script inside the iFrame can read back those variables and do something with them.

Basically starting with http://someurl.com/page.html in your iFrame and dynamically changing it to http://someurl.com/page.html?action=do-something&with=this. Since we're talking Javascript, you can force the iFrame to refresh asynchronously, giving the illusion that it's loading new, interactive data.

EAMann
this would actually refresh all your inner frame, so if you fill a form and the iframe is dynamically re-loaded, you lose your data.
thelost
that's what I understand from EAMann's approach; BTW: see my latest edit
thelost
If you refresh the inner page without storing the data, you'll lose the data. Can you give a more specific example of what you're trying to achieve? Is the iFrame a form? What data are you trying to pass between the iFrame and its page?
EAMann
My solution for this would be to have the iFrame also set a cookie and track its data in the cookie. Then, if it's refreshed by the outside window, it has access to both the new data (from the outside window) and the old data (from the cookie) and can pull the two together.
EAMann
ah ok cool :) ill give that go. thanks for your help!
Tom