IE 6/7 Access Denied trying to access a popup window.document

前端 未结 4 461
星月不相逢
星月不相逢 2021-01-14 17:49

I\'m creating a popup window with no URL source using window.open(). I don\'t give it a URL because soon I\'ll want to post a form to it. However, in the meantime I\'d lik

相关标签:
4条回答
  • 2021-01-14 18:33
    <a href="#" onclick="return test();">Test</a>
    <script type="text/javascript">
    function test() {
        window.open('javascript:opener.write(window);', '_name', 'width=200,height=200');
    }
    function write(w) {
        w.document.write("Hello, World.");
    }
    </script>
    

    Works in IE 6, 7 & 8, Opera 9.6, Firefox 2 & 3. Does not work in Safari for Windows 3 & 4 or Google Chrome.

    When it does work, it results in a pretty ugly URL in the Location box.

    If the browser support listed above is acceptable, you can use the solution provided, otherwise I'd do what David said and window.open('Loading.htm' ...) where Loading.htm contains whatever content you want to display (you should probably keep it lightweight otherwise it might take longer to load and render than the form will to POST).

    0 讨论(0)
  • 2021-01-14 18:33

    Another workaround is to open an empty "blank.htm" file on your site, then do the document.open() to access it

    0 讨论(0)
  • 2021-01-14 18:40

    Also note that the winName you supply in IE must NOT have spaces... if so it will fail.

    0 讨论(0)
  • 2021-01-14 18:49

    IE considers "about:blank" to be a insecure URL and it won't let you talk to it. I would create a "Now Loading..." static HTML file and open that instead.

    0 讨论(0)
提交回复
热议问题