Mark Sandman
Mark Sandman

Reputation: 3333

Is it possible for me to load a lightbox before the page has loaded

I have a pretty large form to develop and it could take some time to render (over 5 secs). Now to give the user an indication of something happening I'd like to fire up a lightbox with a simple "page loading" message whilst the rest of the page loads in the background. Once the page is fully loaded I can close the lightbox and the user can continue through the application. Now I know I shouldn't use window.onload to activate this as jQuery's document.ready is quicker and a better solution for this issue but does anyone have any advice on how to do this or if it's possible.

Upvotes: 1

Views: 424

Answers (2)

gnur
gnur

Reputation: 4733

It is better to just add a semi-transparant div to the dom and and make it disappear onload.
Executing javascript-heavy functions (like the lightbox) kind of defeat the purpose of a waiting indicator.

Upvotes: 2

tbleckert
tbleckert

Reputation: 3801

Add a script in the head (after css is included) that opens the lightbox. Last in the body add a script (preferably with an event handler to know that the dom actually is ready) that closes the lightbox :)

document.addEventListener("DOMContentLoaded", function () {
    //close lightbox
}, false);

Upvotes: 0

Related Questions