Skip to content
Advertisement

Pre-loader Image at page load issue

I am sorry for asking a very minor thing but I feel a bit helpless in this one. I have integrated a pre-loader image at my page load in a very simple way

This is my Page link

HTML: (Div for loading Pre-loader image)

JavaScript

Jquery to trigger the pre-loader on page load

JavaScript

A bit of Styling . CSS

JavaScript

Problem When Page loads, it splashes before the Pre-loader image one time and then loads after the pre-loader image complete its effect. Theoretically, pre-loader should display before page load. I hope anyone of you can figure out where and what I did wrong?

Regards

Advertisement

Answer

I think your HTML isn’t well formatted on the link you provided:

What I would do is make sure the HTML page has a structure similar to this:

JavaScript

And inside your script tag have the following method:

JavaScript

And in your css make sure you set

JavaScript

EDIT: (To answer your question in comment- call loader at any time)

I would probably create a function like this:

JavaScript

Then on window load you would call: toggleLoader(false),

When you make a request call: toggleLoader(true),

And when you receive a response call: toggleLoader(false).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement