Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  123] [ 5]  / answers: 1 / hits: 69179  / 14 Years ago, tue, february 15, 2011, 12:00:00

I did a Google search and I cannot find a way to do a loading with percentage. Anyone know how I can find an example of that?



I need a preload for a website from 0-100 without bar, before show the content, but I cannot find any example.


More From » jquery

 Answers
7

If you mean you want to show the content only when it is fully loaded, you may try following two options:



1) wrap all content inside a <div id=wrapper style=display:none;></div> tag and on load complete event show it like this:



$(function(){
$(#wrapper).show();
});


2) If this still does not solves your purpose, you can load empty page and fetch content using ajax:



$(function(){
$.ajax({
.......//AJAX params
.......
success:function(msg){
$(#wrapper).html(msg);//DO NEEDFUL WITH THE RETURNED VALUE
});
});


EDIT: Using queryLoader script provided by gayadesign I was able to achieve some success :D



I had to made some changes to the queryLoader.js file from line 127 to 151. The changed script is as follows. Try it yourself.



$(QueryLoader.loadBar).css({
position: relative,
top: 50%,
font-size:40px;
font-weight:bold;
line-height:50px;
height:50px;
width:100px;
});
},

animateLoader: function() {
var perc = (100 / QueryLoader.doneStatus) * QueryLoader.doneNow;
if (perc > 99) {
$(QueryLoader.loadBar).stop().animate({
width: perc + %
}, 5000, linear, function() {
$(this).html(<strong>100%</strong>);//MY EDIT
QueryLoader.doneLoad();
});
} else {
$(QueryLoader.loadBar).stop().animate({
width: perc + %
}, 5000, linear, function() {
//MY EDIT
$(this).html(<strong>+Math.round(perc)+%</strong>);
});
}
},

[#93732] Sunday, February 13, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kadinl

Total Points: 321
Total Questions: 117
Total Answers: 103

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;