prevent escaping special characters on textnode(JS-HTML)
- by UnLoCo
Hello
i followed this snippet http://bytes.com/topic/javascript/answers/504399-get-all-text-nodes
var xPathResult = document.evaluate(
'.//text()[normalize-space(.) != ""]',
document.body, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null ); for (var i = 0, l = xPathResult.snapshotLength; i < l; i++) {
var textNode = xPathResult.snapshotItem(i);
textNode.data = textNode.data.replace(/somePattern/g, 'replacement');
}
i want to replace certain patterns like for example |12| with a corresponding emoticon !
but when i do textNode.data.replace("|12|",'<.img src="favicon.ico"/>'); for example
the text show is ..<.img src="favicon.ico"/>..
as i inspect the html i find that <.img src="favicon.ico"/> became escaped to <img src="favicon.ico"/>
is it possible to prevent this and to let the image show ??
Thank You
Note: added extra point here <.img src="favicon.ico"/> in purpose