Reputation: 5622
I have a page from a 3rdparty I want to post to another page into an iframe so that tha layout is maintained. So i have host.com/pageA. This contains the form
host.com/pageB This contains the iframe
vendor.com/reallyComplicatedUrlthatSoundsFancyButMeansNothing
I want to post the results from pageA to pageB where the pageB contains the iframe into which the results are posted.
Target=iframe doesn't work since the iframe is on another page.
Please help
Upvotes: 0
Views: 3240
Reputation: 1
i think the only way is using GET method, like:
<iframe src="host.com/pageB?firstparm=1&secoundparm=2..."</iframe>
Upvotes: 0
Reputation: 31270
It will have to be done in combination of server and client code. Something like...
PageA.php
<form action="PageB.php" method="post">
<input name="field1">
<input name="field2">
<input type="hidden" name="PageAToPageB" value="SomeString">
</form>
PageB.php
<?php
if ($_POST["PageAToPageB"] == "SomeString")
{
?>
<form id="PageAToPageBForm" target="iFrameName" method="post">
<input name="field1" value="<?= $_POST['field1'] ?>">
<input name="field2" value="<?= $_POST['field2'] ?>">
</form>
<script type="text/javascript">
$(function(){
$("#PageAToPageBForm").submit();
});
</script>
<?php
}
?>
Upvotes: 1
Reputation: 11
You will need to "prepare" you parent page...try this way:
Your links in page A would be
<a href="pageb.htm?iframepage1.htm">Iframe page 1</a>
<a href="pageb.htm?iframepage2.htm">Iframe page 2</a>
In page B
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script type="text/javascript">
<!--
function loadIframe(){
if (location.search.length > 0){
url = unescape(location.search.substring(1))
window.frames["myiframe"].location=url
}
}
onload=loadIframe
//-->
</script>
</HEAD>
<BODY>
<iframe name="myiframe" id="myiframe" src=""></iframe>
</BODY>
</HTML>
Upvotes: 0