Possible Duplicate:
Is it possible to call Javascript function in parent document from JS in iframe?
I have a main.php page.
This contains an iframe which src is random.php.
How can I have script in the main.php with a random function, random(), and let random.php use that function?
If you are working with HTML5, you can use the
postMessage()function..here is a nice demo:
http://html5demos.com/postmessage
UPDATE
The idea is to
postMessageto the iframewindowobject, each window is listening to the message event like so:In your main.php:
in your iframe (random.php):