0

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);
    }
user1520277
  • 59
  • 2
  • 11
  • Provide a [mcve] – Asons Jun 12 '19 at 18:01
  • Beside the above, this might be useful: https://stackoverflow.com/questions/2109205/open-window-in-javascript-with-html-inserted – Asons Jun 12 '19 at 18:01
  • Which version of IE are you using? I can't reproduce your issue in my IE11 which version is 11.116.18362.0. Please provide related codes including html codes so that we can reproduce the issue and give a solution. And about the 'Access Denied' problem, you can refer to [this thread](https://stackoverflow.com/questions/1886547/access-is-denied-javascript-error-when-trying-to-access-the-document-object-of). – Yu Zhou Jun 13 '19 at 02:31

0 Answers0