2014-02-26 1 views
1

POST 정보에 다음 정보를 사용하고 있으며 양식 요소를 만들 때 "Permission denied"예외가 발생합니다.정보를 다른 페이지에 POST 할 때 권한이 거부 되었습니까?

var newWindow = window.open('', '_blank', 'alwaysRaised=yes,toolbars=no, menubar=no, location=no, scrollbars=yes, resizable=yes, status=yes,left=10000, top=10000, width=10, height=10, visible=none', ''); 

var tempFormElement = newWindow.document.createElement('form'); 
tempFormElement.method = 'post'; 
tempFormElement.action = urlToOpen; 

var tempInputElement; 
tempInputElement = newWindow.document.createElement('input'); 
tempInputElement.setAttribute('TPLInfo', JSON.stringify(linkageInfo)); 
tempFormElement.appendChild(tempInputElement); 
tempFormElement.submit(); 

newWindow.document.body.removeChild(tempFormElement); 
newWindow.close(); 

제안 해주십시오.

+0

@mplungjan -이 당신이 (이 마지막 두 줄에 대한 문제가 발생할 수 있지만) 작업이되도록 설정 할 수 있는지에 대한 제한은 없으며, 영업 이익은 오류가 어쨌든 두 줄 그 전에 말한다 . – Quentin

+0

누락 된 변수에 대한 데이터를 추가 한 후에 문제를 재현 할 수 없습니다. 유일한 오류는 body에서 tempFormElement를 제거하려고 시도한 경우입니다 (본문에 추가하지 않았기 때문에). – Quentin

+0

웹 서버에서 10px보다 작은 pos 10000 창을 열 수 있습니까? – mplungjan

답변

1
  1. 보안 제한 사항으로 인해, 대부분의 브라우저는 요즘 당신이보기 포트 외부 새 창 을 만들거나보다 작은 100 × 100
  2. 당신이 새 창을 열 필요가 없습니다 허용하지 않습니다 - 대신 사용 AJAX
  3. urlToOpen이 다른 도메인에 있기 때문에 AJAX를 사용할 수 없다면 어쨌든 창을 닫거나 tempform 요소를 제거 할 수 없습니다.
  4. 이 같은 기원에 그렇게 할 수 중 하나가 제출 한 후 더 이상 존재하지 않기 때문에

TPLInfo라고 입력 요소의 유효한 속성이 그래서 내가 제안하지가

  • - 당신이 할 수있는 경우 :

    :
    $.post(urlToOpen,{"TPLInfo":JSON.stringify(linkageInfo)}); 
    

    또는 그렇지 않은 경우와 동일한 도메인 (일반 JS)에 jQuery를

    를 사용

    아약스

    Live Demo

    var newWindow; 
    var urlToOpen = "...."; 
    function perform() { 
         if (!newWindow) { 
         alert("Sorry, you must allow popups"); 
         return; 
         } 
         var tempFormElement = newWindow.document.createElement('form'); 
         tempFormElement.method = 'post'; 
         tempFormElement.action = urlToOpen; 
         var tempInputElement; 
         tempInputElement = newWindow.document.createElement('input'); 
         tempInputElement.setAttribute("name","TPLInfo"); 
         tempInputElement.value = JSON.stringify({"a":"1"}); 
         tempFormElement.appendChild(tempInputElement); 
         newWindow.document.body.appendChild(tempFormElement); 
         tempFormElement.submit(); 
    } 
    window.onload=function() { 
        document.getElementById("but").onclick=function() { 
    // var parms = "alwaysRaised=yes,toolbars=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=yes,left=10000,top=10000,width=10,height=10,visible=none"; 
         // valid parms, yes I know you want to hide and close but nope. 
         var parms = "scrollbars,resizable,status,left=10000,top=10000,width=100,height=100"; 
    
         newWindow = window.open('', '_blank',parms); 
         setTimeout(perform,500); // give IE time to get over opening 
        } 
    } 
    
  • 관련 문제