How to create a new HTMLDocument in IE?

dcoument.implementation.createHTMLDocument [2] is one of the less well-known DOM methods that (unexpectedly!) creates a completely new HTML document.

Unsurprisingly, browser support is pretty poor, but I found some workarounds:

  • Use XLSTProcessor (crazy stuff!) In Firefox <4
  • Create an empty iFrame:

    var iframe = document.createElement('iframe');
    iframe.style = 'display: none';
    iframe.src = 'data:text/html,<!DOCTYPE html><title></title><body>';
    document.body.appendChild(iframe);
    newHTMLDocument = iframe.contentDocument; // <- we need this.
    document.body.removeChild(iframe);
    

However, since IE does not support the scheme datain the iframe, there is no way in IE to do this. Or is there?

+3
source share
1 answer

How to install srcon about:blank?
(And possibly document.writean empty HTML document)

+2
source

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


All Articles