Short answer:
It's a compatibility issue. The JScript 5 engine (IE7/IE8) was severely flawed, and this is one of the things it does (stripping the "
s from attributes and altering capitalization when generating an innerHTML
string). As well, because innerHTML
screws with capitalization, it's trying to match your .split("</div>");
against a string containing </DIV>
and failing.
Try using .split(/<\/div>/i);
instead. This won't solve the loss of "
s from your attributes, but it's a partial fix. See this answer for a function that appears to fix missing quotes and capitalization if the quotes are necessary.
In the larger issue of how to test against older versions of IE:
In essence, the Browser Mode doesn't do anything to how Internet Explorer renders the page1. Browser mode influences how IE acquires the page, changing the UserAgent sent to the server.
Document Mode changes which version of the Trident rendering engine, and whether the IE9 Chakra Javascript engine or the IE8/IE7 variants of the JScript engine are used.
TL;DR, for testing purposes you should change the Browser Mode to IE8, then observe whether the Document Mode defaults to IE8 Standards or Quirks. If the code is not working, toggle between the two. If the code then works, make sure you're setting an appropriate DOCTYPE for whichever mode works (Transitional for Quirks mode, Strict for Standards mode).
[1] Browser Mode also influences how the browser interprets conditional comments, and the default Document Mode (makes it match the Browser Mode), so changing only this is a good way of figuring out how IE8 will interpret the page... but this behavior breaks quickly if you have X-UA-Compatible Meta tags, so if you're using those, just set Document Mode to match.