Following javascript is being used to open a window. It creates a form and then submit data to different server. This code executes when I click a button in my web application. First time it works fine. It open a window and post data but when I close newly opened window and click on the same button again IE throws "Access Denied" at last line pWindow.document.write(html);
Please let me know if you have any suggestion for me.
function openWindowWithPost(url, windowName, windowOptions, params) {
pWindow = null;
pWindow = window.open("", windowName, windowOptions);
if (!pWindow) return false;
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
for (var i in params) {
if (params.hasOwnProperty(i)) {
html += "<input type='hidden' name='" + i + "' value='" + params[i] + "'/>";
}
}
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
pWindow.document.write(html);
}