2011-12-09 3 views
4

내 양식에서 다른 도메인에있는 IFRAME으로 데이터를 POST하려고합니다. 이 작업을 수행하는 쉬운 방법이 있습니까?도메인 간 게시 iframe

<iframe name="iframe" width="100" height="100" src="www.otherdomain.com" /> 

<form action="www.mydomain.com" method="post" target="iframe"> 
<input type="text" name="text1" value="123" /> 
<input type="text" name="text2" value="456" /> 
<input type="submit" value="submit"/> 
</form> 

답변

5

나는 당신의 예제가 효과가 있다고 생각합니다. 내 localhost에 두 개의 가상 호스트 pastefrom.com pasteto.com 을 설정했습니다.

http://pastefrom.com/index.html :

<!DOCTYPE HTML> 
<html> 
<head> 
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
    <title>test</title> 
</head> 
<body> 
<iframe name="iframe" id="iframe" src="http://pasteto.com/index.php" width="500" height="500"></iframe> 

<form action="http://pasteto.com/index.php" method="post" target="iframe"> 
    <input type="text" name="search" value="google" /> 
    <input type="submit" value="submit"/> 
</form> 

</body> 
</html> 

http://pasteto.com/index.php :

<pre><?php var_dump($_POST);?></pre> 

과에 제출는 pasteto.com

array(1) { 
    ["search"]=> 
    string(6) "google" 
} 
에 포스트 데이터를 보여줍니다