There is no guarantee with innerHTML that it will return content identical to the line you passed to. innerHTML is created by the browser using its HTML tree representation, so it will create the resulting string as it sees fits.
Thus, depending on your needs, you can try using HTML parsing code that understands the identifier without quotes around OR try to convince the browser to use the latest engine, which is more likely to give you innerHTML.
those. in your case it looks at least IE9 displays your HTML as IE9: Quirks mode (which returns innerHTML in a way that doesn't suit you), if you make valid HTML or force mode for IE9: Standard you will get a line with qoutes like
document.getElementsByTagName("html")[0].innerHTML
IE9: Standards - "<head></head><body><div id="TEST"></div></body>"
IE9: Quirks -
"<HEAD></HEAD> <BODY> <DIV id=TEST></DIV></BODY>"
You can try it yourself by creating a sample HTML file and opening it from disk. F12 to show developer tools and test mode in the menu bar.
source share