Home > Web Front-end > JS Tutorial > JS implementation of updating web content without flickering_javascript skills

JS implementation of updating web content without flickering_javascript skills

WBOY
Release: 2016-05-16 17:08:08
Original
1395 people have browsed it

todo list

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.

The final solution is

Copy the code The code is as follows:

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 = '

text here

';
var el = str2DOMElement(markup );
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template