Does anyone know why if you use document.body.innerHTML += \"content\"; the JavaScript on the page stops working? I have the following code:
document.body.innerHTML += "content";
Does three things:
innerHTMLinnerHTML with the new valueThis deletes the page and then creates a new one.
Since script elements inserted with innerHTML are not executed, this kills the JS.
Don't append data using innerHTML. Generate DOM nodes (with createElement, createTextNode and friends) and then append them (with appendChild, insertBefore and so on).