I want to show the user that the document which he wants to access
is loading and not ready yet.
I want to show the web-page when it is fully loaded.
I use
$(document).ready(function(){});
for document ready. What should I do for my approach?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first thing to do is ask why the page is so slow to load that you feel you need a loading banner, and to do whatever you can to fix that.
If you can’t fix that because of the nature of the page in question, the next consideration is making sure that the “Loading” banner only appears for people who have JavaScript enabled (because we’re going to remove it later with JavaScript, so it would be a bit mean to put it there and then not remove it if they don’t have JavaScript). This may be one of the few valid remaining uses of the
document.writestatement (and only if you’re not using XHTML, because it’s not valid in XHTML):…which you’d style with CSS, presumably:
And then in your
readyhandler, remove it:If you’re using XHTML (or you just don’t want to use
document.writeon principle), you can do something similar withoutdocument.write, along the lines of:Live example (Tested on IE6/7/8 on Windows; Safari on Windows; and Chrome, Opera, and Firefox on Linux and Windows.)