I have a heavy javascript job that prevents me from showing progress to the user. Is there any way to force refresh the window?
$("button").click(function()
{
var date = new Date();
for (var i = 0; i< 238801000000000000; i++) {
if (new Date() - date > 5000) {
document.getElementById('iddds').innerHTML = 'FINISH';
return;
}
if ((i % 10000) == 0) {
var el = document.getElementById('iddds');
el.innerHTML = i;
redraw(el, document.getElementById('parent'));
console.log(i);
}
}
});
function redraw(element, e3lement) {
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<div id='parent'>
<span id='iddds'>Hello world!!!!!!!!!!!!!</span>
</div>
<button>START</button>
</html>
I've tried all the answers given here: How can I force WebKit to redraw/repaint to propagate style changes? and Force DOM redraw/refresh on Chrome/Mac - and these didn't work, so I assume it is impossible, but given that there are many people who +'d the answers I thought maybe I'm doing something wrong?
- My heavy job is DOM manipulation - Web Workers will not work here.
- I could try to split the job with
setTimeout
's or something similar, but I do not really want to delay the job or make it slower just to be able to show the progress.