IE 6/7 Access Denied access to a popup. Document

I am creating a popup without source URL using window.open (). I don’t give him the URL, because soon I will want to publish the form. However, at the same time, I would like to display a short message "Now loading ..." so that the user does not look at the blank page for 2-3 seconds, after which the form message should pass.

I tried adding Javascript that just writes to the popup document. This worked great in Firefox and IE 8, but failed with an access denied message in IE 6 and 7. Does anyone know about this? I would like to be able to: a) hard-code some HTML in window.open (), b) learn how to update the pop-up DOM in this situation, or c) hear something you might think about.

Below is the code that I use to create the window:

    var wref = window.open("", winName, "toolbar=1,resizable=1,menubar=1,location=1,status=1,scrollbars=1,width=800,height=600");
    if (wref != null) {
        try {wref.opener = self;} catch (exc) {}

        // while we wait for the handoff form post to go through, display a simple wait message
        $j(wref.document.body).html('Now loading …'); // EPIC FAIL
        wref.focus();
+3
source share
4 answers
<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 and 8, Opera 9.6, Firefox 2 and 3. Does not work in Safari for Windows 3 and 4 or Google Chrome.

When it works, it leads to a rather ugly URL in the Location field.

, , , , window.open('Loading.htm' ...), Loading.htm , (, , , POST).

+6

IE "about: blank" URL-, . HTML "Now Loading..." .

+8

, winName, IE, ... .

+1

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

0
source

Source: https://habr.com/ru/post/1706190/


All Articles