I am trying to create a pseudo-report that shows me errors when importing data. For this, I have two functions:
let createHtmlErrorReport = (err) => {
let currentDate = new Date().toLocaleString();
let contents = '<!DOCTYPE html> ' +
'<html>' +
'<head>' +
'<title>Import Inventory Import</title>' +
'<meta charset="utf-8" />' +
'<meta http-equiv="Content-Language" content="en">' +
'<style type="text/css">' +
' html { margin:0; }' +
' body { background-color:#d6d6d6; font: 10pt sans-serif;}' +
'ul li{ padding: 3px; font:12pt;}'+
' #header {padding:10px; background-color:#007fcc; color:#ffffff; } ' +
'</style>' +
'</head>' +
'<body>' +
'<div id="header">'+
'<strong>Import Inventory Import</strong>' +
'</div>' +
'<p><strong>Imported ' + currentDate + ' by ' + err.username + ' | ' + err.unprocessedItemsCount + ' items not imported | ' + err.processedItemsCount + ' items imported | '+ err.errorMessages.length + ' errors.</strong></p>'+
'<p>The following errors occured during import: </p>'+
'<div id="errorList" style="padding:5px;"></div>'+
'</body>' +
'</html>';
return contents;
}
In the above example, I create a new document, add some basic style and create a div container where I want the error list to be inserted.
<div id="errorList" style="padding:5px;"></div>
The following function calls this method and builds a list of errors
let generateImportErrorReport = (errors) => {
let doc = createHtmlErrorReport(errors);
let errorReportWindow = window.open('', '_blank');
errorReportWindow.document.write(doc);
let list = document.createElement('ul');
for (let i = 0; i < errors.errorMessages.length; i++) {
let item = document.createElement('li');
let message = errorReportWindow.document.createTextNode(errors.errorMessages[i]);
item.appendChild(message);
list.appendChild(item);;
}
}
A list is nothing more than an array of strings:
errors.errorMessages = [
{'Message 1'},
{'Message 2'}
]
This code works fine in Chrome and Firefox, however a new document is created in IE, but this list is never added to the selected item. I can see the created element, but it will not be added to the newly created document.
Internally IE dev tools capture a common message Error: No such interface supported
SO , , , html, , .
**: , js typescript angular. TS ECMA3 , .
, .