2012-06-15 4 views
0

forma poupup 창을 게시하고 싶습니다. 문제는 양식이 성공적으로 게시되지만 부모 창에 게시된다는 것입니다. 나는 팝업 창에서 formonly을 제출하려는부모가 아닌 양식을 팝업 창에 게시하십시오.

'<input type= button value ="Submit Form" onclick="adNetworkForm()" > 
<script> 
function adNetworkForm(){ 
targetUrl = "http://somesite.com"  
    var myForm = document.createElement('form'); 
    myForm.method = 'post'; 
    //myForm.action = targetUrl;   

    var inpt1 = document.createElement('input'); 
    inpt1.setAttribute('name','a'); 
    inpt1.setAttribute('type', 'hidden') 
    inpt1.value = "1"; 

    var inpt2 = document.createElement('input'); 
    inpt2.setAttribute('name','b'); 
    inpt2.setAttribute('type', 'hidden') 
    inpt2.value = 2; 
    myForm.appendChild(inpt1); 
    myForm.appendChild(inpt2); 
    document.body.appendChild(myForm); 
    myForm.submit(popitup(targetUrl)); 
    document.body.removeChild(myForm); 
} 

function popitup(url) { 
newwindow=window.open(url,'name','height=600,width=500'); 
if (window.focus) {newwindow.focus()} 
return false; 
} 

</script>​' 

JS Fiddle

+0

[Window.open 및 post 매개 변수로 매개 변수 전달] 가능한 복제본 (http://stackoverflow.com/questions/3951768/window-open-and-pass-parameters- by-post-method) –

답변

5

당신이 양식을 제출 열어 새 창을 팝업 폼을 대상으로하는 함수를 호출하는 형태로 onsubmit 이벤트 핸들러를 할당 할 수 같은 그 창에 :

<form action="..." method="post" onsubmit="some_popup_post(this);"> 
<!-- form fields etc here --> 
</form> 

그리고 JS 코드는 다음과 같습니다

function some_popup_post(form) { 
    window.open('', 'formpopup', 'width=400,height=400,resizeable,scrollbars'); 
    form.target = 'formpopup'; 
} 
,

다음과 같은 것을 의미합니까?

관련 문제