So, I\'ve been trying stuff lately and got this piece of code in my script:
document.body.bgColor = \"red\";
alert(\"hello\");
But in Chrom
The rendering process has a lifecycle of it's own and does not block the javascript thread. They both work independently.
The solution is to "pause" the JavaScript execution to let the rendering threads catch up. This can be done via a simple setTimeout set to 0
document.body.style.backgroundColor = "red";
setTimeout(function() {
alert("hey");
}, 0)
Note that bgColor has been deprecated since 2003 with the DOM Level 2 Spec. The current way to set the background color of an element is via element.style.backgroundColor.