It doesn't seem to be the write() method which causes IE11 to crash but instead is related to close(). The best answer found on a similar issue
Why won't this JavaScript (using document.open and document.write) work in Internet Explorer or Opera? found that not including the close() call stopped IE from crashing.
I had a similar issue myself:
var doc = document.implementation.createHTMLDocument('');
doc.open();
doc.write('<body><p>Hello world</p>');
doc.close(); // This is where it breaks
However I've not had any luck actually calling the method without it breaking the page. I've tried adding it to timeouts or only closing when I finished with the DOM but all seem to fail. I guess it's a case of detecting IE11 and not calling close.
if (!(window.ActiveXObject) && "ActiveXObject" in window) {
// IE11, do nothing... may cause memory leaks...
} else {
doc.close();
}
I've only tried IE11 but it might crash out in earlier versions of IE as well... in that case use
if ("ActiveXObject" in window) {
// IE, do nothing... may cause memory leaks...
} else {
doc.close();
}
Hope this helps anyone experiencing the same issue.