I am creating a in browser HTML editor. I am using the syntax highlighter called Code Mirror which is very good.
My setup is an iframe that holds a view of the page
try
iframe[0].documentElement.innerHTML = code;
Assuming that the url to the iframe is from the same domain as the webpage.