Updating web pages without flickering is a big issue.
The loaded html string (obtained through ajax), if you still need to run the code, then there must be a problem.
I hope to use a non-displayed iframe to host this object. This feels a bit like dirty work.
var str2DOMElement = function( html) {
var frame = document.createElement('iframe');
frame.style.display = 'none';
document.body.appendChild(frame);
frame.contentDocument. open();
frame.contentDocument.write(html);
frame.contentDocument.close();
var el = frame.contentDocument.body.firstChild;
document.body.removeChild( frame);
return el;
}
var markup = '
';
var el = str2DOMElement(markup );