I've been working recently with trying to create DIV's on the fly. i.e. a user clicks on an element, and that generates the innerHTML of some DIV on the page.
For instance, I might have:
<p><a href="#" onclick="someFunction('theDiv');">Generate</a><p>
Clicking on the Generate link would set the innerHTML of the div named theDiv to be set to some arbitrary string (lets say its the string below):
<p>Hello World for the first time.</p>
The problem I am having is when I try to write the "Hello World" string to the innerHTML several hundred/thousand times. Basically I loop through a list, and write the "hello world" top a string until the loop is done, and then I write it out to innerHTML. This causes the browser to slow down and become unresponsive for a few seconds. The greater the number of lines the longer the pause/slowdown.
Is there a faster way to write to the document? Using the DOM is too slow, and I don't need to programatically access any of these newly created nodes so I don't think that will help any. I haven't seen chunking the data out to innerHTML make much of a diffrrence (i.e. writing to innerHTML every X number of lines) from my brief tests either.
Thanks in advance,