Reputation: 10213
From what I knew, the browser suppose to stop rendering DOM whenever it reaches a script, until the scripts are completed.
However, if I write a
window.open('Mypage.aspx?ID=0', '_top');
at the head tag I can still see a quick 'flicker' before the new page is opened. I even tried to create an artificial delay before the body tag but to no avail. How can I avoid that flicker?
Example:
<html>
<head>
<title>aa</title>
<script type="text/javascript">window.open('MyPage.aspx?ID=0', '_top');
var now = new Date().getTime();
while(new Date().getTime() < now + 3000){ /* force delay */ }
</script></head><body style="background-color:red">
initial page
</body>
Upvotes: 2
Views: 118
Reputation: 385
In Chrome you could use window.stop();
in the first line of your script which will stop html rendering.
Although for me it seems more consistent to manage it with css classes to hide/show the when it's appropiate.
Upvotes: 2