2012-09-04 2 views
1

IE 컨트롤이 포함 된 winforms 응용 프로그램이 있습니다.IE7에서 window.open() 이후의 사용 권한이 거부되었습니다.

IE 컨트롤에서는 웹 응용 프로그램을 실행하지만 웹 응용 프로그램은 제어하지만 winforms 응용 프로그램은 제어하지 않습니다. 웹 응용 프로그램에서

, 나는 실행 하위 창을 열고 HTML로를 채울 일부 자바 스크립트 :

var features = "menubar=no,location=no,resizable,scrollbars,status=no,width=800,height=600,top=10,left=10"; 
    newTarget = "reportWin" + String (Math.random() * 1000000000000).replace(/\./g ,""); 
    reportWindow = window.open('', newTarget, features); 
    var d = reportWindow.document; // <-- Exception is thrown here 
    d.open(); 
    d.write('<head>\r\n<title>\r\n...\r\n</title>\r\n</head>'); 
    d.write('<body style="height: 90%;">\r\n<table style="height: 100%; width: 100%;" border="0">\r\n<tr>\r\n<td align="center" valign="middle" style="text-align:center;">\r\n'); 
    d.write(...); 
    d.close(); 

우리는 (그러나 그 자체로도 다른이 윈폼 응용 프로그램 내에서 웹 응용 프로그램을 실행할 때 윈폼 응용 프로그램) 우리가 표시 줄에서 자바 스크립트 오류가 발생합니다 : 이런 일이 아니면 내가 그것을 피할 수있는 방법에있을 수있는 이유에

Line 0: Access denied 

어떤 아이디어? 창은 URL을 열지 않습니다. 그것은 단지 빈 창입니다.

동일한 응용 프로그램에서 동일한 도메인의 지정된 URL로 창을 열면 작동합니다. 을 바탕으로

+0

팝업 차단기가 작동하지 않았습니까? –

+0

창이 열리기 때문에 팝업 차단기로 보이지 않습니다. 문제는 winodw 내에서 문서 개체에 액세스하려고하는 것입니다. – antlersoft

답변

5

:

  1. IE 6/7 Access Denied trying to access a popup window.document
  2. http://thecodecave.com/2006/07/20/how-to-get-around-access-is-denied-in-a-windowopen-javascript-call/

당신이 겪고있는 문제는 URL이을 여는 페이지와 같은 도메인에있을 필요에 열리는 것입니다. 아마도 빈 URL은 제작자의 도메인을 공유하지 않을 것입니다. 몇 가지 간단한 테스트 웹 페이지를 작성하여 찾았습니다.

  1. var reportWindow = window.open('', newTarget, features);을 호출하면 액세스가 거부되었습니다.

    window.document.open(); 
    window.document.write('<head>\r\n<title>\r\n...\r\n</title>\r\n</head>'); 
    window.document.write('test<body style="height: 90%;">\r\n<table style="height: 100%; width: 100%;" border="0">\r\n<tr>\r\n<td align="center" valign="middle" style="text-align:center;">\r\n'); 
    window.document.close(); 
    
    : 렌더링이 var reportWindow = window.open('WebForm2.aspx', newTarget, features);

작동합니까 var reportWindow = window.open('http://google.com', newTarget, features);

  • 그러나 개방 않는 사이트의 다른 페이지와
  • 같은 일이 마지막이 코드를 실행 WebForm2.aspx를 가리키는 창을 팝업
  • +0

    완벽하게 작동합니다. 감사합니다. – David

    관련 문제