0

I want to render responsetext in my document which is inside an iframe. I am using document.write(responsetext) which works fine for all browsers except IE11.

Is there any alternative or workaround for this?

Also, it works fine in IE if this is done outside iframe.

The following code snippet is submitting a form using Ajax Post request.

Ext.Ajax.request({
            method: 'POST',
            url: g_globalsFromJsp.contextPath + '/UploadAction0.do',
            params: formData,
            success: function (response, opts) {
                        if (response.status ===200) { // OK
                            //Error Here
                            document.open();
                            document.write(response.responseText);
                            document.close();
                        }
            },
            failure : function(response, opts) {
                //SomeAlertMessage
            }
        })

Edit: There are two different web pages involved in my issue. I will call them P1 and P2. P2 contains the above-mentioned code snippet and works fine independently. But When P2 is called from an iframe inside P1 the iframe goes blank in IE11. Also from P2 I cannot access the iframe.

  • That can't be true, `dw` in an ajax callback would wipe out the current document in any browser. – Teemu Nov 14 '17 at 10:52
  • Unfortunately it is happening in my case – Ankit Bansal Nov 14 '17 at 10:56
  • No, I can't belive this, caching, something overrides `dw` in other browsers ... anything but the way you've described. It is just not possible. Please show the code you have. – Teemu Nov 14 '17 at 10:59
  • @AnkitBansal Do you have a sample somewhere which we can open in IE and Chrome to see for ourselves? – Alexander Nov 14 '17 at 11:42
  • @Alexander I will try to generate a sample in some time, I don't have ready-made sample – Ankit Bansal Nov 14 '17 at 12:52
  • Your code should simply clear the document where the script is run, unless there's some wicked hidden code, which redefines `document` and/or its [`write`](https://developer.mozilla.org/en-US/docs/Web/API/Document/write) method. And this happens in all browsers, not only in IE. – Teemu Nov 14 '17 at 13:01
  • The code ofcourse should create new content to the new document. If it doesn't in IE, you should take a carefull look into the HTML you're trying to write to the file. IE has some issues concerning invalid HTML (among other issues it has). – Teemu Nov 14 '17 at 13:32
  • When I am commenting out document.open() IE is rendering the page, although not exactly same as other browsers. Not able to understand the reason behind it. – Ankit Bansal Nov 14 '17 at 16:39
  • `document.write` calls `open()` implicitly when it is called after the pages has been parsed, hence calling it explicitly is not needed (in any browser). It shouldn't have any affect to the execution, though. Diffrerent rendering is a trademark of IE, if you've issues with that, you should post a new question. – Teemu Nov 14 '17 at 17:09
  • @AnkitBansal, did you find a solution for this? – Rakesh Makluri Oct 12 '20 at 18:32
  • If you are using `document.open()` before `document.write()` like I did try removing that – Ankit Bansal Oct 14 '20 at 03:31

0 Answers0