How do I replace the entire HTML node using jQuery

Solution 1:

The document.open/write/close methods will do what you want:

var newDoc = document.open("text/html", "replace");
newDoc.write(myString);
newDoc.close();

Unless you pass in the replace parameter, the document.open call adds page history. So users would have to click back twice to go to the previous page.

Solution 2:

You could just strip out the html tags, and then put everything inside the html element:

$('html').html(myString.replace(/<html>(.*)<\/html>/, "$1"));