[英]Post a form into an iframe on another page
I have a page from a 3rdparty I want to post to another page into an iframe so that tha layout is maintained. 我有一个来自3rdparty的页面,我想将其发布到另一个页面到iframe中,以便保持布局。 So i have host.com/pageA.
所以我有host.com/pageA。 This contains the form
这包含表格
host.com/pageB This contains the iframe host.com/pageB包含iframe
vendor.com/reallyComplicatedUrlthatSoundsFancyButMeansNothing 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. 我想将结果从pageA发布到pageB,其中pageB包含将结果发布到其中的iframe。
Target=iframe doesn't work since the iframe is on another page. 由于iframe位于另一页上,因此Target = iframe无法正常工作。
Please help 请帮忙
It will have to be done in combination of server and client code. 它必须结合服务器和客户端代码来完成。 Something like...
就像是...
PageA.php PageA.php
<form action="PageB.php" method="post">
<input name="field1">
<input name="field2">
<input type="hidden" name="PageAToPageB" value="SomeString">
</form>
PageB.php 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
}
?>
我认为唯一的方法是使用GET方法,例如:
<iframe src="host.com/pageB?firstparm=1&secoundparm=2..."</iframe>
You will need to "prepare" you parent page...try this way: 您将需要“准备”您的父页面...尝试这种方式:
Your links in page A would be 您在A页中的链接为
<a href="pageb.htm?iframepage1.htm">Iframe page 1</a> <a href="pageb.htm?iframepage2.htm">Iframe page 2</a>
In page B 在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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.