title: Unescape HTML entities containing newline in Javascript?
body: <p>If you have a string containing HTML entities and want to unescape it, this solution (or variants thereof) is suggested multiple times:</p>
  
  <pre><code>function htmlDecode(input){
    var e = document.createElement('div');
    e.innerHTML = input;
    return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
  }
  
  htmlDecode("&amp;lt;img src='myimage.jpg'&amp;gt;"); 
  // returns "&lt;img src='myimage.jpg'&gt;"
  </code></pre>
  
  <p>(See, for example, this answer: <a href="https://stackoverflow.com/a/1912522/1199564">https://stackoverflow.com/a/1912522/1199564</a>)</p>
  
  <p>This works fine as long as the string does <em>not</em> contain newline and we are <em>not</em> running on Internet Explorer version pre 10 (tested on version 9 and 8).</p>
  
  <p>If the string contains a newline, IE 8 and 9 will replace it with a space character instead of leaving it unchanged (as it is on Chrome, Safari, Firefox and IE 10).</p>
  
  <pre><code>htmlDecode("Hello\nWorld"); 
  // returns "Hello World" on IE 8 and 9
  </code></pre>
  
  <p>Any suggestions for a solution that works with IE before version 10?</p>