Answer the question
In order to leave comments, you need to log in
How to make the preloader load immediately when the page loads?
I use a preloader that I found on the Internet, I like it very much and it suits me, but how can I make it load immediately after the page is loaded, i.e. the orange field was already visible from the first second, and not half a second or a second after the page was loaded?
Working example
And this is in the footer:
<div id="hellopreloader">
<div id="hellopreloader_preload"></div>
</div>
<script type="text/javascript">
var hellopreloader = document.getElementById("hellopreloader_preload");
function fadeOutnojquery(el) {
el.style.opacity = 1;
var interhellopreloader = setInterval(function () {
el.style.opacity = el.style.opacity - 0.05;
if (el.style.opacity <= 0.05) {
clearInterval(interhellopreloader);
hellopreloader.style.display = "none";
}
}, 16);
}
window.onload = function () {
setTimeout(function () {
fadeOutnojquery(hellopreloader);
}, 0);
};
</script>
Answer the question
In order to leave comments, you need to log in
Put preloader in header (not in <head>)
<div id="hellopreloader">
<div id="hellopreloader_preload"></div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question