When working with iFrames is it possible to pass data to an iframe first and then have the iframe load a page based on data passed to it?

StackOverflow https://stackoverflow.com/questions/19712090

Question

Basically I have this PHP page (call it the parent frame or container) and it will receive $_POST data from another website. However, within the parent frame or container page I need to have an iframe loading a page containing a form. However, I would like to be able to pass the $_POST data to the page specified within the iframe before the iframe page loads so that it can load content based on the $_POST data passed to it from the parent frame.

Is this possible and if so, is it possible also in Internet Explorer browsers 9 and 10? I ask about IE because I'm used to the fact that most things just work on Firefox and Chrome and those are the three browsers that my client cares about supporting.

Was it helpful?

Solution

Would it be acceptable to pass the POST data to the iframe via GET? If so, you could load the iframe with:

src="iframe.php?data=<?php echo urlencode($_POST['data']) ?>"

OTHER TIPS

Just use GET variables

Send post data to your iframe:

<iframe src="form.php?var=<?php echo urlencode($_POST['yourdata']); ?>" />.

In your form.php you can retrieve the value of var using $_GET['var']:

<?php echo htmlspecialchars($_GET['var']); //will output *yourdata* ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top