I'm writing a MUD client with HTML web-sockets where I'm receiving HTML from the MUD server. Essentially think of it as a chat-client.
When I receive data from the MUD server to be presented in a two column horizontal layout, it will only work if I receive the entire data at once, whereas if I receive it a line at a time, it will turn the nice two column format into a single column layout.
Sample code to reproduce the issue is here. I'm hoping there's some kind of solution to this which would not require assembling the entire string before adding it to innerHTML as shown in the third solution.
The incorrect formatting is the same in both FF and Chrome which makes me hope there's a solution to the challenge :-)
<html>
<body>
<br/><hr/>
<!-- *** Conversation Output *** -->
<div id="static" role="log" aria-live="polite" width="100%">
what it should look like: <br/>
<table class='twocolhor'>
<tr><td><wielded></td><td><div class='wielded'>a hand mace</div></td></tr>
<tr><td><worn about body></td><td><div class='wielded'>white robes of a healer</div></td></tr>
<tr><td><worn on feet></td><td><div class='wielded'>a pair of sandals</div></td></tr>
</table>
</div>
<br/><hr/>
<div id="incomingMsgOutput2" role="log" aria-live="polite" width="100%">
Sample, this will NOT work<br/>
</div>
<br/><hr/>
<div id="incomingMsgOutput3" role="log" aria-live="polite" width="100%">
Sample, this will work<br/>
</div>
</body>
<script>
var obj = document.getElementById("incomingMsgOutput2");
obj.innerHTML += "<table class='twocolhor'>"
obj.innerHTML += "<tr><td><wielded></td><td><div class='wielded'>a hand mace</div></td></tr>"
obj.innerHTML += "<tr><td><worn about body></td><td><div class='wielded'>white robes of a healer</div></td></tr>"
obj.innerHTML += "<tr><td><worn on feet></td><td><div class='wielded'>a pair of sandals</div></td></tr>"
obj.innerHTML += "</table>"
var obj = document.getElementById("incomingMsgOutput3");
obj.innerHTML += "<table class='twocolhor'>" + "<tr><td><wielded></td><td><div class='wielded'>a hand mace</div></td></tr>" +
"<tr><td><worn about body></td><td><div class='wielded'>white robes of a healer</div></td></tr>" +
"<tr><td><worn on feet></td><td><div class='wielded'>a pair of sandals</div></td></tr>" +
"</table>"
</script>
</html>