1
2
3
4
5
var pre = document.createElement('pre');
pre.appendChild(document.createTextNode(source));
document.body.appendChild(pre);

//as a side note: innerText was made by IE, but supported by anyone but FireFox, textContent is standard, but not supported in IE8-. fun