views:

101

answers:

2

I want to change the iframe source when something change in this iframe content, the iframe is in a different domian than the parent page. is this can be done or not?

I just need to add a hash to this iframe src, so that i can access this hash value from the parent page and do some stuff based on this value.

What i did:
In the iframe page i wrote: window.location.hash = "close_child";
and in the parent page i wrote: if (document.getElementById("MyIFrameId").src.indexOf("#close_child") > 0) { but i always find that the src is empty

A: 

I'm not 100% sure, but I think you should be able to do this without a problem. Since an iframe is just a frame, you should be able to change the location property from within the code inside the iframe (same as you would for anything else), and that change should be visible to the parent page whenever it is made.

ckramer
A: 

Yes, it can be done. A parent object can NOT see into the iFrame, but the IFrame CAN call a JavaScript procedure from code executing within the iFrame, passing it parameters such as your hash value.

Shadeclan
how? do you have a code sample?
Amr ElGarhy