我们有一个带有嵌入式 IE 控件的 winforms 应用程序。
在这个IE控件中,我们运行一个Web应用程序(我控制Web应用程序,但不控制winforms应用程序)。
在 Web 应用程序中,我运行一些 javascript 来打开一个子窗口并用 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();
当我们在此 WinForms 应用程序中运行 Web 应用程序(但不是单独运行,也不是在另一个 WinForms 应用程序中)时,我们在指定的行处收到 Javascript 错误:
Line 0: Access denied
关于为什么会发生这种情况或如何避免这种情况有什么想法吗?请注意,该窗口并未打开 URL;而是打开了 URL。这只是一个空窗口。
从同一个应用程序中,打开具有同一域中指定 URL 的窗口确实有效。