I am looking to have everything on my page hidden until the page has finished loading. I have seen many posts and tried different things.
The most common solution which works great is
<body style="display:none;">
Then run jQuery to show it again upon window load
$(window).load(function() {
$("body").fadeIn("slow");
});
I have an issue with this, as the page is reliant on JS to show anything at all. I appreciate this is a rare thing, but just feels wrong.
Ideally I would like to use jQuery to add the display:none css as well
however...
The problem is when I add
$(document).ready(function {
$(body).css('display', 'none');
});
Even this takes a while to run and the page flickers with content before hand.
Is there a better way?
Could I use the above script without document.ready (tried, but didn;t work)
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…