I need to print in a new window with a string html tags html. What I did is:
function printNewTab(toPrint, title) {
var newWin = window.open("about:blank");
newWin.document.write("<html><head><title>" + title + "</title></head></html>");
newWin.document.write(toPrint.toString());
console.log(title + ":");
console.log(toPrint);
}
but if I have a string like this:
var s = "<h1>title<u> number</u> 1</h1>";
and use the method above:
printNewTab(s, "title");
I obtain a new window where the text does not display tags but is formatted in html.
While I'd really like to see printed <h1>title<u> number</u> 1</h1>
.
How can I do this?
Thanks!